protected void gvInstitute_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteRecord") { if (e.CommandArgument != null) { InstituteBAL balInstitute = new InstituteBAL(); if (balInstitute.Delete(Convert.ToInt32(e.CommandArgument.ToString().Trim()))) { FillGridViewInstitute(); } else { PanelErrorMesseage.Visible = true; lblErrorMesseage.Text = balInstitute.Message; } } } else if (e.CommandName == "EditRecord") { if (e.CommandArgument != null) { Response.Redirect(e.CommandArgument.ToString().Trim()); } } }
protected void btnSave_Click(object sender, EventArgs e) { #region Server Side Validation String strError = ""; if (txtInstituteName.Text.Trim() == "") { strError += "Enter Institute +</br>"; } if (strError.Trim() != "") { PanelErrorMesseage.Visible = true; lblErrorMesseage.Text = strError; return; } #endregion Server Side Validation #region Collect Data InstituteENT entInstitute = new InstituteENT(); if (txtInstituteName.Text.Trim() != "") { entInstitute.InstituteName = txtInstituteName.Text.Trim(); } #endregion Collect Data InstituteBAL balInstitute = new InstituteBAL(); if (Request.QueryString["InstituteID"] == null) { if (balInstitute.Insert(entInstitute)) { clearSelection(); PanelSuccess.Visible = true; lblSuccess.Text = "Data Inserted Successfully"; } else { PanelErrorMesseage.Visible = true; lblErrorMesseage.Text = balInstitute.Message; } } else { entInstitute.InstituteID = Convert.ToInt32(Request.QueryString["InstituteID"].ToString().Trim()); if (balInstitute.Update(entInstitute)) { Response.Redirect("~/Content/Institute/InstituteList.aspx"); } else { PanelErrorMesseage.Visible = true; lblErrorMesseage.Text = balInstitute.Message; } } }
public static void fillDropDownListInstitute(DropDownList ddl) { InstituteBAL balInstitute = new InstituteBAL(); ddl.DataSource = balInstitute.SelectForDropDownList(); ddl.DataValueField = "InstituteID"; ddl.DataTextField = "InstituteName"; ddl.DataBind(); ddl.Items.Insert(0, new ListItem(" --Select Institute--", "-1")); }
private void fillControls(SqlInt32 InstituteID) { InstituteBAL balInstitute = new InstituteBAL(); InstituteENT entInstitute = new InstituteENT(); entInstitute = balInstitute.SelectByPK(InstituteID); if (!entInstitute.InstituteName.IsNull) { txtInstituteName.Text = entInstitute.InstituteName.Value.ToString(); } }
private void FillGridViewInstitute() { InstituteBAL balInstitute = new InstituteBAL(); DataTable dtInstitute = new DataTable(); dtInstitute = balInstitute.SelectAll(); if (dtInstitute != null && dtInstitute.Rows.Count > 0) { gvInstitute.DataSource = dtInstitute; gvInstitute.DataBind(); } }