First add this code on the .aspx file to add checkboxes to GridView
Then locate
protected void gv_RowDeleting(object sender, GridViewDeleteEventArgs e) for your GridView and place the code below.
// Looping through all the rows in the GridView
foreach (GridViewRow row in gv.Rows)
{
CheckBox checkbox = (CheckBox)row.FindControl("chkDeleteRows");
//Check if the checkbox is checked.
if (checkbox.Checked)
{
// Pass the Row ID to the DeleteList function
DeleteList(Convert.ToInt32(gv.DataKeys[row.RowIndex].Values[0]));
// DataKeys should be defined in the GridView property on the aspx page along with the delete button handler like this (OnRowDeleting="gv_RowDeleting")
// DataKeyNames="ROWID" (this should be the Primary Key in the table.)
}
}
binoj_daniel
Practically a Master Poster
645 posts since Dec 2006
Reputation Points: 25
Solved Threads: 18