Back to Devexpress

How to: Show ASPxCardView's Detail Information in ASPxDataView

aspnet-115474-components-card-view-examples-how-to-show-aspxcardviews-detail-information-in-aspxdataview.md

latest2.8 KB
Original Source

How to: Show ASPxCardView's Detail Information in ASPxDataView

  • Dec 17, 2020

The example below demonstrates how to show ASPxCardView’s detail data.

js
function FocusedCardChanged(s, e) {
    dataview.PerformCallback(s.GetCardKey(s.GetFocusedCardIndex()));
}
aspx
<dx:ASPxCardView ID="ASPxCardView1" runat="server" AutoGenerateColumns="False" DataSourceID="AccessDataSource2"
    KeyFieldName="CategoryID" ClientInstanceName="cardview">
    <SettingsBehavior AllowFocusedCard="True" />
    <ClientSideEvents FocusedCardChanged="FocusedCardChanged" />
    <Columns>
        <dx:CardViewTextColumn FieldName="CategoryID" ReadOnly="True" />
        <dx:CardViewTextColumn FieldName="CategoryName" />
        <dx:CardViewTextColumn FieldName="Description" />
    </Columns>
</dx:ASPxCardView>

<dx:ASPxDataView ID="ASPxDataView1" runat="server" SettingsTableLayout-ColumnCount="1" DataSourceID="AccessDataSource1"
        SettingsTableLayout-RowsPerPage="1" ClientInstanceName="dataview" OnCustomCallback="ASPxDataView1_CustomCallback"
    OnLoad="ASPxDataView1_Load">
    <ItemTemplate>
        <b>ProductID</b>:
        <asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>' />
        

        <b>ProductName</b>:
        <asp:Label ID="ProductNameLabel" runat="server" Text='<%# Eval("ProductName") %>' />
        

        <b>CategoryID</b>:
        <asp:Label ID="CategoryIDLabel" runat="server" Text='<%# Eval("CategoryID") %>' />
        

    </ItemTemplate>
</dx:ASPxDataView>

csharp
protected void ASPxDataView1_CustomCallback(object sender, DevExpress.Web.CallbackEventArgsBase e) {
    Session["CategoryID"] = e.Parameter;
    AccessDataSource1.SelectParameters["CategoryID"].DefaultValue = e.Parameter;
    (sender as ASPxDataView).DataBind();
}
protected void ASPxDataView1_Load(object sender, EventArgs e) {
    if (Session["CategoryID"] == null) return;
    AccessDataSource1.SelectParameters["CategoryID"].DefaultValue = Session["CategoryID"].ToString();
    (sender as ASPxDataView).DataBind();
}
vb
Protected Sub ASPxDataView1_CustomCallback(ByVal sender As Object, ByVal e As DevExpress.Web.CallbackEventArgsBase)
    Session("CategoryID") = e.Parameter
    AccessDataSource1.SelectParameters("CategoryID").DefaultValue = e.Parameter
    TryCast(sender, ASPxDataView).DataBind()
End Sub
Protected Sub ASPxDataView1_Load(ByVal sender As Object, ByVal e As EventArgs)
    If Session("CategoryID") Is Nothing Then
        Return
    End If
    AccessDataSource1.SelectParameters("CategoryID").DefaultValue = Session("CategoryID").ToString()
    TryCast(sender, ASPxDataView).DataBind()
End Sub