protected void Page_Load(object sender, EventArgs e) { if (IsPostBack == false) { GradingFactorTypeBLL objGFT = new GradingFactorTypeBLL(); List <GradingFactorTypeBLL> list = objGFT.GetActiveGradingfactorType(); if (list != null) { this.cboGradingFactorType.AppendDataBoundItems = true; this.cboSearchGradingFactorTypeId.AppendDataBoundItems = true; foreach (GradingFactorTypeBLL i in list) { this.cboGradingFactorType.Items.Add(new ListItem(i.GradingFactorTypeName, i.Id.ToString())); this.cboSearchGradingFactorTypeId.Items.Add(new ListItem(i.GradingFactorTypeName, i.Id.ToString())); } this.cboGradingFactorType.AppendDataBoundItems = false; this.cboSearchGradingFactorTypeId.AppendDataBoundItems = false; } } else { //GridViewRow rw = this.gvGF.Rows[this.gvGF.EditIndex]; //DropDownList dr = (DropDownList)rw.FindControl("cboEditGradingFactorType"); } }
public static List <GradingFactorTypeBLL> GetActive() { string strSql = "spActiveGradingFactorType"; List <GradingFactorTypeBLL> list; SqlDataReader reader; SqlConnection conn = Connection.getConnection(); reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql); if (reader.HasRows) { list = new List <GradingFactorTypeBLL>(); while (reader.Read()) { GradingFactorTypeBLL obj = new GradingFactorTypeBLL(); if (reader["Id"] != DBNull.Value) { obj.Id = new Guid(reader["Id"].ToString()); } if (reader["GradingFactorTypeName"] != DBNull.Value) { obj.GradingFactorTypeName = reader["GradingFactorTypeName"].ToString(); } if (reader["ValueType"] != DBNull.Value) { obj.ValueType = reader["ValueType"].ToString(); } if (reader["Status"] != DBNull.Value) { obj.Status = (int.Parse(reader["Status"].ToString())); } list.Add(obj); } if (conn.State == ConnectionState.Open) { conn.Close(); } return(list); } else { if (conn.State == ConnectionState.Open) { conn.Close(); } return(null); } }
protected void gvGF_RowDataBound(object sender, GridViewRowEventArgs e) { if (this.gvGF.EditIndex == e.Row.RowIndex && this.gvGF.EditIndex != -1) { GridViewRow rw = e.Row; //Update the Grading Factor Name GradingFactorBLL objOld = new GradingFactorBLL(); Label lblId = (Label)rw.FindControl("lblEditId"); TextBox txtGFN = (TextBox)rw.FindControl("txtGradingFactorName"); DropDownList dr = (DropDownList)rw.FindControl("cboEditGradingFactorType"); DropDownList drStatus = (DropDownList)rw.FindControl("cboEditStatus"); Label lblGTId = (Label)rw.FindControl("GradingTypeId"); if (lblId != null) { objOld.Id = new Guid(lblId.Text); } if (txtGFN != null) { objOld.GradingFactorName = txtGFN.Text; } if (dr != null) { objOld.GradingTypeId = new Guid(lblGTId.Text); objOld.GradingFactorTypeName = dr.SelectedItem.ToString(); } if (drStatus != null) { if (drStatus.SelectedValue != "") { if (drStatus.SelectedValue == "Active") { objOld.Status = GradingFactorStatus.Active; } else if (drStatus.SelectedValue == "Cancelled") { objOld.Status = GradingFactorStatus.Cancelled; } } } ViewState["OldGF"] = objOld; GradingFactorTypeBLL objGFT = new GradingFactorTypeBLL(); List <GradingFactorTypeBLL> listGFT = objGFT.GetActiveGradingfactorType(); if (dr != null) { if (listGFT != null) { dr.Items.Clear(); dr.AppendDataBoundItems = true; foreach (GradingFactorTypeBLL i in listGFT) { dr.Items.Add(new ListItem(i.GradingFactorTypeName, i.Id.ToString())); } dr.AppendDataBoundItems = false; } } if (lblGTId != null) { dr.SelectedValue = lblGTId.Text; } } }