Skip to main content
Tab

ASPxCardView.FocusedCardChanged Event

Fires after the focused card has been changed.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v22.1.dll

Declaration

public event EventHandler FocusedCardChanged

Event Data

The FocusedCardChanged event's data class is EventArgs.

Remarks

The FocusedCardChanged event is raised when an end-user moves focus from one card to another or after the ASPxCardView.FocusedCardIndex property’s value has been changed in code.

If the ASPxCardViewBehaviorSettings.ProcessFocusedCardChangedOnServer property is set to false, the ASPxClientCardView.FocusedCardChanged event is handled on the client side without a callback to the server. Setting this property to true indicates that the final processing of the event should be performed on the server side, and so a round trip to the server is required. During such a round trip the corresponding server-side FocusedCardChanged event is fired, which if handled, allows any desired server-side action to be performed.

Example

The example below demonstrates how to show ASPxCardView’s detail data. You can also refer to the following DevExpress Support Center example: T272616: ASPxCardView - How to display master-detail data using two ASPxCardView controls.

View Example

<head runat="server">
    <title></title>
    <script type="text/javascript">
        function FocusedCardChanged(s, e) {
            dataview.PerformCallback(s.GetCardKey(s.GetFocusedCardIndex()));
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <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" VisibleIndex="0">
                </dx:CardViewTextColumn>
                <dx:CardViewTextColumn FieldName="CategoryName" VisibleIndex="1">
                </dx:CardViewTextColumn>
                <dx:CardViewTextColumn FieldName="Description" VisibleIndex="2">
                </dx:CardViewTextColumn>
            </Columns>
        </dx:ASPxCardView>
            <asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/nwind.mdb"
                SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]">
            </asp:AccessDataSource>
        <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") %>' />
                <br />
                <b>ProductName</b>:
                <asp:Label ID="ProductNameLabel" runat="server" Text='<%# Eval("ProductName") %>' />
                <br />
                <b>CategoryID</b>:
                <asp:Label ID="CategoryIDLabel" runat="server" Text='<%# Eval("CategoryID") %>' />
                <br />
            </ItemTemplate>
        </dx:ASPxDataView>
        <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/nwind.mdb"
            SelectCommand="SELECT [ProductID], [ProductName], [CategoryID] FROM [Products] WHERE ([CategoryID] = @CategoryID)">
            <SelectParameters>
                <asp:Parameter DefaultValue="1" Name="CategoryID" Type="Int32" />
            </SelectParameters>
        </asp:AccessDataSource>
    </div>
    </form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e) {

    }
    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();
    }
}
See Also