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"); } }
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; } } }