Skip to main content

How to: Create a Custom Command Button

The following example creates a custom command button for the ASPxCardView control.

The CardView stores custom command buttons (CardViewCustomCommandButton instances) within its CardViewCommandLayoutItem.CustomButtons collection at the CardViewCommandLayoutItem object level.

<dx:ASPxCardView ID="ASPxCardView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" KeyFieldName="ProductID">
<SettingsExport ExportSelectedCardsOnly="False"></SettingsExport>
    <Columns>
        <dx:CardViewTextColumn FieldName="ProductName" VisibleIndex="0">
        </dx:CardViewTextColumn>
        <dx:CardViewTextColumn FieldName="UnitPrice" VisibleIndex="1">
        </dx:CardViewTextColumn>
    </Columns>
<EditFormLayoutProperties ColCount="1"></EditFormLayoutProperties>
<CardLayoutProperties ColCount="1">
    <Items>
        <dx:CardViewColumnLayoutItem ColumnName="ProductName" />
        <dx:CardViewColumnLayoutItem ColumnName="UnitPrice" />
        <dx:CardViewCommandLayoutItem ButtonRenderMode="Button">
            <CustomButtons>
                <dx:CardViewCustomCommandButton ID="CustomButtonID"
                    Text="Custom Action" 
                    Styles-Style-Width="100%"></dx:CardViewCustomCommandButton>
            </CustomButtons>
        </dx:CardViewCommandLayoutItem>
    </Items>
</CardLayoutProperties>
<StylesExport>
<Card BorderSize="1" BorderSides="All"></Card>
<Group BorderSize="1" BorderSides="All"></Group>
<TabbedGroup BorderSize="1" BorderSides="All"></TabbedGroup>
<Tab BorderSize="1"></Tab>
</StylesExport>
</dx:ASPxCardView>