Skip to main content
A newer version of this page is available. .
Tab

ASPxCardView.CustomButtonInitialize Event

Enables you to initialize custom command buttons.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v19.1.dll

Declaration

public event ASPxCardViewCustomButtonEventHandler CustomButtonInitialize

Event Data

The CustomButtonInitialize event's data class is ASPxCardViewCustomCommandButtonEventArgs. The following properties provide information specific to this event:

Property Description
ButtonID Gets the processed custom button’s identifier. Inherited from ASPxGridCustomCommandButtonEventArgs.
Enabled Gets or sets a value that specifies whether the processed custom button is enabled. Inherited from ASPxGridCustomCommandButtonEventArgs.
Image Gets the settings of an image displayed within the processed custom button. Inherited from ASPxGridCustomCommandButtonEventArgs.
IsEditingCard Gets whether a custom command button is displayed within the card currently being edited.
LayoutItem Gets the command layout item which owns the processed command button.
RenderMode Specifies the processed custom command button’s render mode. Inherited from ASPxGridCustomCommandButtonEventArgs.
Styles Gets the processed custom button’s style. Inherited from ASPxGridCustomCommandButtonEventArgs.
Text Gets or sets the processed custom button’s text. Inherited from ASPxGridCustomCommandButtonEventArgs.
Visible Gets or sets whether the processed custom button is visible. Inherited from ASPxGridCustomCommandButtonEventArgs.
VisibleIndex Gets the visible index of a data item (row, card or record) which contains the processed custom button. Inherited from ASPxGridCustomCommandButtonEventArgs.

Remarks

The CustomButtonInitialize event is raised for each custom command button, and enables you to initialize it. For instance, you can handle this event to hide individual buttons.

The event parameter’s properties allow you to identify the button, card, the type of cell which contains the processed button, etc.

To initialize individual built-in command buttons (edit, new, delete, etc.), handle the ASPxCardView.CommandButtonInitialize event.

Note

If you call the GetCardValues method in the CustomButtonInitialize event handler, you should take into account the specific behavior described in the ASPxCardView.GetCardValues topic.

Note

It is impossible to change the style of the selection checkbox using the CustomButtonInitialize event.

Example

The example demonstrates how to specify the CommandButtons and Custom CommandButtons properties by handling the CommandButtonInitialize and CustomButtonInitialize events. The DataRows’ VisibleIndex property and criteria set based on field values are used to determine the buttons’ visibility.

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

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <dx:ASPxCardView ID="ASPxCardView1" runat="server" DataSourceID="AccessDataSource1" OnCustomButtonInitialize="ASPxCardView1_CustomButtonInitialize" OnCommandButtonInitialize="ASPxCardView1_CommandButtonInitialize" KeyFieldName="ProductID" AutoGenerateColumns="False">
        <ClientSideEvents CustomButtonClick="function(s, e) {        
            alert('keyValue = ' + s.GetCardKey(e.visibleIndex));    
}" />
        <SettingsBehavior AllowFocusedCard="true" />
        <Columns>
            <dx:CardViewTextColumn FieldName="ProductID" VisibleIndex="2" ReadOnly="True">
            </dx:CardViewTextColumn>
            <dx:CardViewTextColumn FieldName="ProductName" VisibleIndex="0">
            </dx:CardViewTextColumn>
            <dx:CardViewTextColumn FieldName="UnitPrice" VisibleIndex="1">
            </dx:CardViewTextColumn>
        </Columns>
        <CardLayoutProperties>
            <Items>
                <dx:CardViewCommandLayoutItem HorizontalAlign="Right" ShowDeleteButton="True" ShowEditButton="True">
                </dx:CardViewCommandLayoutItem>
                <dx:CardViewColumnLayoutItem ColumnName="ProductID">
                </dx:CardViewColumnLayoutItem>
                <dx:CardViewColumnLayoutItem ColumnName="Product Name">
                </dx:CardViewColumnLayoutItem>
                <dx:CardViewColumnLayoutItem ColumnName="UnitPrice">
                </dx:CardViewColumnLayoutItem>                
            </Items>
        </CardLayoutProperties>        
        </dx:ASPxCardView>  
    <br />
    <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/nwind.mdb"
        SelectCommand="SELECT [ProductID], [ProductName], [UnitPrice] FROM [Products]" DeleteCommand="DELETE FROM [Products] WHERE [ProductID] = ?" InsertCommand="INSERT INTO [Products] ([ProductID], [ProductName], [UnitPrice]) VALUES (?, ?, ?)" UpdateCommand="UPDATE [Products] SET [ProductName] = ?, [UnitPrice] = ? WHERE [ProductID] = ?" >
        <DeleteParameters>
            <asp:Parameter Name="ProductID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="ProductID" Type="Int32" />
            <asp:Parameter Name="ProductName" Type="String" />
            <asp:Parameter Name="UnitPrice" Type="Decimal" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="ProductName" Type="String" />
            <asp:Parameter Name="UnitPrice" Type="Decimal" />
            <asp:Parameter Name="ProductID" Type="Int32" />
        </UpdateParameters>
        </asp:AccessDataSource>
    </div>
    </form>
</body>
</html>
See Also