Skip to main content

How to: Use a Hyperlink in CardView Column Cells

  • 3 minutes to read

Developers often need to include several field values in a hyperlink displayed in CardView column cells. We recommend that you use templates in this instance. The following example uses two similar approaches to show how this is implemented:

1) In a simple case, the href parameter of the <a> element is defined by the KeyValue of the processed card. 2) In a complex case, the href parameter of the <a> element is defined in the server-side GetCardValues(Int32, String[]) method.

View Example

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="DevExpress.Web.v15.1, Version=, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
    <title>How to use a hyperlink whose argument depends on several cell values in the ASPxCardView</title>
    <form id="form1" runat="server">
    <dx:ASPxCardView ID="ASPxCardView1" DataSourceID="AccessDataSource2" KeyFieldName="CategoryID" PreviewFieldName="Notes" AutoGenerateColumns="False" EnableCardsCache="False" ClientInstanceName="cardview" runat="server" Width="1000px">
            <SettingsTableLayout ColumnCount="2" RowsPerPage="2" />
        <SettingsBehavior AllowFocusedCard="True" ConfirmDelete="True" />

            <dx:CardViewTextColumn FieldName="CategoryID" ReadOnly="True" VisibleIndex="0">
            <dx:CardViewTextColumn FieldName="CategoryName" VisibleIndex="1">
            <dx:CardViewTextColumn FieldName="Description" VisibleIndex="2">
            <dx:CardViewTextColumn Caption="Simple Hyperlink Column" VisibleIndex="3">
                    <a id="clickElement" target="_blank" href="Default2.aspx?id=<%# Container.KeyValue%>"><%# "Show New Form, Key Field = " + Eval("CategoryID").ToString()%></a>
            <dx:CardViewTextColumn Caption="Complex Hyperlink Column" VisibleIndex="4">
                    <a id="A1" target="_blank" href="Default2.aspx?id=<%# GetCardValue(Container)%>"><%# "Show New Form, CategoryName = " + Eval("CategoryName").ToString()%></a>

        <asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/nwind.mdb"
        SelectCommand="SELECT * FROM [Categories]">