protected void btnDelete_Click(object sender, EventArgs e) { foreach (GridViewRow row in gvInstructors.Rows) { CheckBox cb = (CheckBox)row.FindControl("DeleteSelector"); if (cb != null && cb.Checked) { int id = Convert.ToInt32(gvInstructors.DataKeys[row.RowIndex].Value); InstructorsDAL idal = new InstructorsDAL(); idal.DeleteInstructor(id); InstructorsDAL ld = new InstructorsDAL(); DataSet ds = ld.getInstructors(); gvInstructors.DataSource = ds; gvInstructors.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { try { this.Master.name.Text = Session["User"].ToString(); } catch (Exception ex) { Response.Redirect("index.aspx"); } InstructorsDAL ld = new InstructorsDAL(); DataSet ds = ld.getInstructors(); gvInstructors.DataSource = ds; gvInstructors.DataBind(); lblNo.Visible = false; if (ds.Tables[0].Rows.Count == 0) { btnDelete.Visible = false; lblNo.Visible = true; } }