ASP.NET - deleteing a row in checkbox - Asked By raju singh on 13-Feb-12 11:20 AM

how to delete a row in gridview when it is checked using with c sharp and sql..
Web Star replied to raju singh on 13-Feb-12 11:31 AM
On delete button click event just check which checkbox in gridview are checked that will be deleted
dipa ahuja replied to raju singh on 13-Feb-12 11:33 AM
protected void btnDeleteSelected_Click(object sender, EventArgs e)
  foreach (GridViewRow row in GridView1.Rows)
    if (((CheckBox)row.FindControl("checkBox1")).Checked == true)
      /* Get Table Id From Row */
      string id = GridView1.Rows[row.RowIndex].Cells[0].Text;
      /* delete from database */
      SqlConnection con = new SqlConnection("Connection String");
      SqlCommand comm = new SqlCommand("delete from TableName where id='" + id + "'", con);
  /* Refresh the Grid*/
kalpana aparnathi replied to raju singh on 13-Feb-12 01:32 PM

For your solution