Skip to content

DevExpress-Examples/asp-net-web-forms-grid-use-aspxcheckbox-to-emulate-selection

Repository files navigation

Grid View for ASP.NET Web Forms - How to use ASPxCheckBox in DataItemTemplate to implement a selection column

This example demonstrates how to emulate the selection behavior in ASPxGridView control.

Implementation Details

DataItemTemplate contains a ASPxCheckBox control. The CheckedChanged event handler calls the SelectRowOnPage method to select or deselect the corresponding row.

<dx:GridViewDataTextColumn Caption="#" >
    <DataItemTemplate>
        <dxe:ASPxCheckBox ID="cbCheck" runat="server" AutoPostBack="false" OnLoad="cbCheck_Load" />
    </DataItemTemplate>
    ...
</dx:GridViewDataTextColumn>
protected void cbCheck_Load(object sender, EventArgs e) {
    ...
    cb.ClientSideEvents.CheckedChanged = String.Format("function (s, e) {{ grid.SelectRowOnPage ({0}, s.GetChecked()); }}", container.VisibleIndex);
}

HeaderTemplate contains a ASPxCheckBox control to implement select all functionality. For this check box, the CheckedChanged event handler calls the SelectAllRowsOnPage method to select or deselect all grid rows.

<dx:GridViewDataTextColumn Caption="#" >
    ...
    <HeaderTemplate >
        <dxe:ASPxCheckBox ID="SelectAllCheckBox" runat="server" ToolTip="Select/Unselect all rows on the page"
            ClientSideEvents-CheckedChanged="function(s, e) { grid.SelectAllRowsOnPage(s.GetChecked()); grid.PerformCallback(); }" />
    </HeaderTemplate>
</dx:GridViewDataTextColumn>

Files to Review

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Emulate the selection behavior in grid with ASPxCheckBox control.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •