Sunday, June 1, 2008

SPGridView - Deleting a row

The signature of the Deleting event handler when u select the Delete link button :

private void gridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{

int rowIndex = e.RowIndex; // This gets you the row that u just clicked on the Delete button
GridViewRow row = gridView.Rows[rowIndex];

//To reference a particular column in that row, you can:
row.Cell[0].Text
// Where 0 is the reference to the first column in row.

//Since this gridview is binded to the datatable, just remove the row from the datatable and re bind to the grid view.

}

No comments: