/// <summary> /// method to bind values from database to consultant type dropdownlist /// </summary> private void BindConsultantTypes() { DrpConsultantType.DataSource = (new ConsultantTypeBLL()).GetConsultantType(); DrpConsultantType.DataTextField = "ConsultantType"; DrpConsultantType.DataValueField = "ConsultantTypeID"; DrpConsultantType.DataBind(); }
/// <summary> /// Clear the Input Fields and set Default data. /// </summary> protected void ClearDetails() { txtConsultantname.Text = string.Empty; TxtContactNum.Text = string.Empty; TxtContactPerson.Text = string.Empty; TxtEmailaddress.Text = string.Empty; TxtAddress.Text = string.Empty; DrpConsultantType.ClearSelection(); }
/// <summary> /// Set edit mode for edit comand /// Delete data from the database for delete comand /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grdConsultant_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditRow") { ViewState["CONSULTANTID"] = e.CommandArgument; ConsultantBO objCon = new ConsultantBO(); ConsultantBLL objConBLL = new ConsultantBLL(); objCon = objConBLL.GetConsultantByID(Convert.ToInt32(ViewState["CONSULTANTID"])); if (objCon != null) { txtConsultantname.Text = objCon.ConsultName; DrpConsultantType.ClearSelection(); if (DrpConsultantType.Items.FindByValue(objCon.ConsultType) != null) { DrpConsultantType.Items.FindByValue(objCon.ConsultType).Selected = true; } TxtEmailaddress.Text = objCon.EmailAddress; TxtAddress.Text = objCon.Address; TxtContactNum.Text = objCon.ConNumber; TxtContactPerson.Text = objCon.ConPerson; } SetUpdateMode(true); } else if (e.CommandName == "DeleteRow") { ConsultantBLL objConBLL = new ConsultantBLL(); objConBLL.DeleteConsultant(Convert.ToInt32(e.CommandArgument)); ClearDetails(); SetUpdateMode(false); BindGrid(false, true); } }