protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int stateId = 0; Label l; l = (Label)GridView1.Rows[e.RowIndex].FindControl("lblStateId"); stateId = int.Parse(l.Text); StateBusinessLayer.DeleteState(stateId); lblMsg.Text = "State Deleted Successfully"; ShowState(); }
protected void btnDelete_Click(object sender, EventArgs e) { CheckBox chk; foreach (GridViewRow gr in GridView1.Rows) { chk = (CheckBox)gr.FindControl("chkId"); if (chk.Checked == true) { Label l; int StateId = 0; l = (Label)gr.FindControl("lblStateId"); StateId = int.Parse(l.Text); StateBusinessLayer.DeleteState(StateId); lblMsg.Text = "State Deleted Successfully"; ShowState(); } } }