Search code examples
c#asp.netgridviewrowcommand

Override rowcommand in gridview


I would like to refresh the page when delete button is clicked in gridview, however I could not find a way to do it, if I write my onrowcommand function

if (e.CommandName == "Delete")
{
Response.Redirect("~/Order.aspx");
}

it does redirect first, and do not delete the record, however I want to be able to delete the record and refresh the page using redirect method afterwards.


Solution

  • Don't use the delete command, but rather the RowDeleted server side event. It fires after the row is deleted and it serves your purpose.

    Link to docs