The example shows how to delete the selected rows of an ASPxGridView that is bound to an in-memory DataSource.
Use the client-side PerformCallback method to send custom callbacks to the server when a user clicks the Delete button.
function OnClickButtonDel(s, e) {
grid.PerformCallback('Delete');
}
...
<dx:ASPxButton ID="buttonDel" AutoPostBack="false"
runat="server" Text="Delete">
<ClientSideEvents Click="OnClickButtonDel"/>
</dx:ASPxButton>
On the server, the PerformCallback
method raises the CustomCallback event.
In the CustomCallback
event handler, call the GetSelectedFieldValues method to obtain the selected rows. Then, call the Remove method for each selected row.
protected void gridView_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) {
if(e.Parameters == "Delete") {
table = GetTable();
List<Object> selectItems = grid.GetSelectedFieldValues("ID");
foreach(object selectItemId in selectItems) {
table.Rows.Remove(table.Rows.Find(selectItemId));
}
grid.DataBind();
grid.Selection.UnselectAll();
}
}
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
- How to Move Selected Rows From the ASPxGridView Into Another ASPxGridView
- How to Edit an In-Memory Dataset
(you will be redirected to DevExpress.com to submit your response)