Skip to main content
Tab

ASPxCardViewEditorEventArgs.VisibleIndex Property

Gets the edited card’s visible index.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v22.2.dll

NuGet Package: DevExpress.Web

Declaration

public int VisibleIndex { get; }

Property Value

Type Description
Int32

An integer value that specifies the edited card’s visible index.

Example

The following example dynamically disables editors on an Edit Form when an editor’s value is changed. This approach cannot be used when edit templates are defined.

View Example

<dx:ASPxCardView ID="ASPxCardView1" ClientInstanceName="grid" OnCardUpdating="ASPxCardView1_CardUpdating" OnCellEditorInitialize="ASPxCardView1_CellEditorInitialize" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" KeyFieldName="ProductID">
    <Columns>
        <dx:CardViewTextColumn FieldName="ProductID" ReadOnly="True" Visible="False">
        </dx:CardViewTextColumn>
        <dx:CardViewTextColumn FieldName="UnitPrice" VisibleIndex="0">
        </dx:CardViewTextColumn>
        <dx:CardViewTextColumn FieldName="UnitsInStock" VisibleIndex="1">
        </dx:CardViewTextColumn>
        <dx:CardViewTextColumn FieldName="UnitsOnOrder" VisibleIndex="2">
        </dx:CardViewTextColumn>
        <dx:CardViewCheckColumn FieldName="Discontinued" VisibleIndex="3">
            <PropertiesCheckEdit>
                <ClientSideEvents CheckedChanged="function(s, e) {
                    for(i = 0; i < grid.GetColumnCount(); i++) {
                        var editor = grid.GetEditor(i);
                        if(editor != null && editor != s)
                            editor.SetEnabled(s.GetChecked());
                    } }" />
            </PropertiesCheckEdit>
        </dx:CardViewCheckColumn>
    </Columns>
    <CardLayoutProperties>
        <Items>
            <dx:CardViewCommandLayoutItem HorizontalAlign="Right" ShowEditButton="True">
            </dx:CardViewCommandLayoutItem>
            <dx:CardViewColumnLayoutItem ColumnName="UnitPrice">
            </dx:CardViewColumnLayoutItem>
            <dx:CardViewColumnLayoutItem ColumnName="UnitsInStock">
            </dx:CardViewColumnLayoutItem>
            <dx:CardViewColumnLayoutItem ColumnName="UnitsOnOrder">
            </dx:CardViewColumnLayoutItem>
            <dx:CardViewColumnLayoutItem ColumnName="Discontinued">
            </dx:CardViewColumnLayoutItem>
            <dx:EditModeCommandLayoutItem HorizontalAlign="Right">
            </dx:EditModeCommandLayoutItem>
        </Items>
    </CardLayoutProperties>
</dx:ASPxCardView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\nwind.mdb;Persist Security Info=True" DeleteCommand="DELETE FROM [Products] WHERE [ProductID] = ?" InsertCommand="INSERT INTO [Products] ([ProductID], [UnitPrice], [UnitsInStock], [UnitsOnOrder], [Discontinued]) VALUES (?, ?, ?, ?, ?)" ProviderName="System.Data.OleDb" SelectCommand="SELECT [ProductID], [UnitPrice], [UnitsInStock], [UnitsOnOrder], [Discontinued] FROM [Products]" UpdateCommand="UPDATE [Products] SET [UnitPrice] = ?, [UnitsInStock] = ?, [UnitsOnOrder] = ?, [Discontinued] = ? WHERE [ProductID] = ?">
    <DeleteParameters>
        <asp:Parameter Name="ProductID" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="ProductID" Type="Int32" />
        <asp:Parameter Name="UnitPrice" Type="Decimal" />
        <asp:Parameter Name="UnitsInStock" Type="Int16" />
        <asp:Parameter Name="UnitsOnOrder" Type="Int16" />
        <asp:Parameter Name="Discontinued" Type="Boolean" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="UnitPrice" Type="Decimal" />
        <asp:Parameter Name="UnitsInStock" Type="Int16" />
        <asp:Parameter Name="UnitsOnOrder" Type="Int16" />
        <asp:Parameter Name="Discontinued" Type="Boolean" />
        <asp:Parameter Name="ProductID" Type="Int32" />
    </UpdateParameters>
</asp:SqlDataSource>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void ASPxCardView1_CardUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) {
            e.Cancel = true;
            ASPxCardView1.CancelEdit();
    }
    protected void ASPxCardView1_CellEditorInitialize(object sender, DevExpress.Web.ASPxCardViewEditorEventArgs e) {
        if (e.Column.FieldName != "Discontinued")
        {
            bool editable = (bool)ASPxCardView1.GetCardValues(e.VisibleIndex, "Discontinued");
            e.Editor.ClientEnabled = editable;
        }
    }
}
See Also