Skip to main content

ASPxCardView.GetDataRow(Int32) Method

Returns a DataRow object that represents the specified card.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web


public DataRow GetDataRow(
    int visibleIndex


Name Type Description
visibleIndex Int32

An integer value that identifies the card.


Type Description

A DataRow object that represents the specified card. null (Nothing in Visual Basic) if the specified card was not found.


The GetDataRow method returns an object that represents a record in a data source. To do this, the ASPxCardView must be bound to a data source. Otherwise, if the grid isn’t bound, the GetDataRow method automatically calls the ASPxWebControl.DataBind method.


Since the GetDataRow method returns a DataRow object, it requires the bound data source support this type of object (e.g. Access Data Source, SQL Data Source). If the bound data source does not support DataRow objects, the GetDataRow method returns null (Nothing in Visual Basic). In this case, you can use the ASPxCardView.GetRow method to get an object that represents the specified row.


The following example handles the CommandButtonInitialize and CustomButtonInitialize events to specify the CommandButtons and CustomCommandButtons properties. The DataRow’s VisibleIndex property and criteria (set based on field values) are used to determine button visibility.

<dx:ASPxCardView ID="ASPxCardView1" runat="server" DataSourceID="AccessDataSource1"         
    KeyFieldName="ProductID" AutoGenerateColumns="False">
    <ClientSideEvents CustomButtonClick="function(s, e) {alert('keyValue = ' + s.GetCardKey(e.visibleIndex));}" />
    <SettingsBehavior AllowFocusedCard="true" />
        <dx:CardViewTextColumn FieldName="ProductName" />
        <dx:CardViewTextColumn FieldName="UnitPrice" />
        <dx:CardViewTextColumn FieldName="ProductID" ReadOnly="True">
            <dx:CardViewCommandLayoutItem HorizontalAlign="Right" 
                                          ShowEditButton="True" />
            <dx:CardViewColumnLayoutItem ColumnName="ProductID" />
            <dx:CardViewColumnLayoutItem ColumnName="Product Name" />
            <dx:CardViewColumnLayoutItem ColumnName="UnitPrice" />
protected void Page_Load(object sender, EventArgs e) {
    if (!IsPostBack) {
        (ASPxCardView1.CardLayoutProperties.Items[0] as CardViewCommandLayoutItem).CustomButtons.Add(CreateCustomButton());
CardViewCustomCommandButton CreateCustomButton() {
    CardViewCustomCommandButton customBtn = new CardViewCustomCommandButton();
    customBtn.ID = "CustomBtn";
    customBtn.Text = "Custom button";
    return customBtn;
protected void ASPxCardView1_CommandButtonInitialize(object sender, ASPxCardViewCommandButtonEventArgs e) {
    if (e.VisibleIndex == -1) return;
    switch (e.ButtonType) {
        case CardViewCommandButtonType.Edit:
            e.Visible = EditButtonVisibleCriteria((ASPxCardView)sender, e.VisibleIndex);
        case CardViewCommandButtonType.Delete:
            e.Visible = DeleteButtonVisibleCriteria((ASPxCardView)sender, e.VisibleIndex);
private bool EditButtonVisibleCriteria(ASPxCardView grid, int visibleIndex) {
    object card = grid.GetDataRow(visibleIndex);
    return ((DataRow)card)["ProductName"].ToString().Contains("a");
private bool DeleteButtonVisibleCriteria(ASPxCardView grid, int visibleIndex) {
    object card = grid.GetDataRow(visibleIndex);
    return ((DataRow)card)["ProductName"].ToString().Contains("b");
protected void ASPxCardView1_CustomButtonInitialize(object sender, ASPxCardViewCustomCommandButtonEventArgs e) {
    if (e.VisibleIndex == -1) return;
    if (e.ButtonID == "CustomBtn" && e.VisibleIndex % 2 != 0)
        e.Visible = DefaultBoolean.False;
See Also