I picked up some code on the internet that allows me to go through the check boxes, see which ones are checked and then return to a label which tasks would be deleted. It didn't provide the code for actually deleting them however and i havent been able to find out how to do it, so i was hoping someone could help me.
My code is below:
Code:
protected void DeleteButton_Click(object sender, GridViewDeleteEventArgs e)
{
bool AtLeastOneRowDeleted = false;
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox cb = (CheckBox)row.FindControl("chk1");
if (cb != null && cb.Checked)
{
AtLeastOneRowDeleted = true;
string TaskName = Convert.ToString(GridView1.DataKeys[row.RowIndex].Value);
DeleteResults.Text += string.Format("This would have deleted task - {0} <br />", TaskName);
DeleteResults.Visible = AtLeastOneRowDeleted;
}
}
}
Any help would be greatly appreciated
