ERROR:Index was out of range. Must be non-negative and less than the size of the collection.
protected void btnDelete_Click(object sender, EventArgs e) { //Loop through all the rows in gridview foreach (GridViewRow GridViewrow in GridView1.Rows) { //Finiding checkbox control in gridview for particular row CheckBox chkdelete = (CheckBox)GridViewrow.FindControl("chkdelete"); //Condition to check checkbox selected or not if (chkdelete.Checked) { //Getting UserId of particular row using datakey value int Sno = Convert.ToInt32(GridView1.DataKeys[GridViewrow.RowIndex].Value.ToString()); SqlDataSource1.DeleteParameters["Sno"].DefaultValue =Sno.ToString(); SqlDataSource1.Delete(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)