protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteRec") { state.StateId = int.Parse(e.CommandArgument.ToString()); state.DeleteState(); lblMsg.Text = "Record Deleted Successfully...!"; GridView1.DataSource = state.ShowAllState(); GridView1.DataBind(); } if (e.CommandName == "UpdateRec") { Response.Redirect("~/Admin/Update/frmUpdateState.aspx?StateId=" + e.CommandArgument); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { Button btn; foreach (GridViewRow gr in GridView1.Rows) { if (gr.RowIndex == e.RowIndex) { btn = (Button)gr.FindControl("btndelete"); state.StateId = int.Parse(btn.CommandArgument.ToString()); } state.DeleteState(); lblMsg.Text = "Deleted...!"; BindData(); } }