G
Guest
Hi,
Trouble in retaining values of dropdownlist, textboxes, and other
controls when
dropdownlist selectedindexchanged event is triggered, the controls are
inside a user control and this user control inside a parent user control with
an update panel. Can you guys help me hwo to retain the values. I have set
EnableViewState to true. Where is correct page event to store entered and
selected values before the values on controls are re-intialized.
Some of the codes:
protected override void OnLoad(EventArgs e)
{
....
this.UpdateContent();
base.OnLoad(e);
if (multiView.GetActiveView().ID == "viewInputForm")
{
if (Session["id"] != null)
ShowAssessmentDetails(Session["id"].ToString());
DisplayProcessedIconImage();
}
}
//All Dropdown SelectedIndexChanged Event
protected void DropDown_SelectedIndexChanged(object sender, EventArgs e)
{
if (sender == this.ddlEmployee)
{
...
}
else if (sender == this.ddlCategory)
{
FillSubCategoryList();
FillCompetencyList();
}
else if (sender == this.ddlSubCategory)
{
if (ddlSubCategory.SelectedIndex != 0)
{
int subcat = Int32.Parse(ddlSubCategory.SelectedValue);
ddlCategory.SelectedValue = oAssessment.GetCategoryID(subcat);
FillSubCategoryList();
ddlSubCategory.SelectedValue = subcat.ToString();
if (subcat.ToString() != string.Empty && subcat.ToString() != "0")
ViewState["ddlSubCategory"] = subcat.ToString();
}
FillCompetencyList();
}
else if (sender == this.ddlCompetencyCode)
{
UpdateCompetencyList(1);
DoCourseCodeMatching();
}
else if (sender == this.ddlCompetency)
{
UpdateCompetencyList(2);
DoCourseCodeMatching();
}
else if (sender == this.ddlCourseCode)
{
ClearSuggestedTrainingData();
//FillTrainingData();
DoCourseCodeMatching();
}
else if (sender == this.ddlYear)
{
...
}
else if (sender == this.ddlCompetencyModel)
{
FillCategoryList();
FillSubCategoryList();
FillCompetencyList();
}
...
}
private void ShowAssessmentDetails(string idVal)
{
oAssessment.ID = Convert.ToInt32(idVal);
if (oAssessment.Get())
{
InitializeControls();
...
FillCompetencyModelList();//First Dropdown
....
FillEmployeeData();
try { ddlCompetencyModel.SelectedValue =
oAssessment.CompetencyModelID.ToString(); }
catch { ddlCompetencyModel.SelectedIndex = 0; }
FillCategoryList();//Second DropDown
FillSubCategoryList();//Third Dropdown
FillCompetencyList();//Fourth Dropdown
FillCourseCode();
ddlCompetency.SelectedValue = oAssessment.CompetencyID.ToString();
UpdateCompetencyList(2);
try { ddlCourseCode.SelectedValue =
oAssessment.CatalogueCourseID.ToString(); }
catch { ddlCourseCode.SelectedIndex = 0; }
....
FillSupervisorApproval(cbTrainingRequest.Checked);
FillLocalApproval(cbTrainingRequest.Checked);
ddlCSApproval.SelectedValue =
oAssessment.CompetencySupervisorApprovalID.ToString();
ddlCLApproval.SelectedValue =
oAssessment.CompetencyLocalApprovalID.ToString();
....
try { ddlSuggLocalTrainingType.SelectedValue =
oAssessment.SuggestedLocalTrainingType.ToString(); }
catch { ddlSuggLocalTrainingType.SelectedIndex = 0; }
tbLocalTrainingSuggest.Text = oAssessment.SuggestedLocalTraining;
try
{
ddlSuggTrainingType.SelectedValue =
oAssessment.SuggestedTrainingType.ToString();
tbSuggestedTraining.Text = oAssessment.SuggestedTraining;
}
catch
{
ddlSuggTrainingType.SelectedIndex = 0;
tbSuggestedTraining.Text = String.Empty;
}
....
}
}
private void InitializeControls()
{
...
FillCompetencyModelList();
...
FillCategoryList();
FillSubCategoryList();
FillCompetencyList();
FillSupervisorApproval(false);
FillLocalApproval(false);
...
FillCourseCode();
...
}
private void FillCompetencyModelList()
{
try
{
using (DataAccessLayer objDAL = new
DataAccessLayer("CompetencyModel_GetAllByYear"))
{
objDAL.AddParameter("Year", ddlYear.SelectedValue);
objDAL.ExecuteReader();
ddlCompetencyModel.Items.Clear();
ddlCompetencyModel.Items.Add(new ListItem("-- select model --", "0"));
while (objDAL.DataReader.Read())
{
ddlCompetencyModel.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencyModelID"])));
}
}
}
catch
{
ddlCompetencyModel.Items.Clear();
ddlCompetencyModel.Items.Add(new ListItem("-- select model --", "0"));
}
}
private void FillCompetencyList()
{
if (ddlCompetencyModel.SelectedIndex != 0)
{
try
{
ddlCompetencyCode.Items.Clear();
ddlCompetency.Items.Clear();
ddlCompetencyCode.Items.Add(new ListItem("-- select code --", "0"));
ddlCompetency.Items.Add(new ListItem("-- select competency --", "0"));
if (ddlCompetencyModel.SelectedIndex == 0)
{
if ((ddlSubCategory.SelectedValue != null) &&
(ddlSubCategory.SelectedValue != "0"))
{
using (DataAccessLayer objDAL = new
DataAccessLayer("Competency_GetBySubCategoryIDAndYear"))
{
SqlParameter sqlparam = new SqlParameter("@subcat", SqlDbType.Int);
sqlparam.Value = ddlSubCategory.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.AddParameter("year", ddlYear.SelectedValue);
objDAL.ExecuteReader();
while (objDAL.DataReader.Read())
{
ddlCompetencyCode.Items.Add(new
ListItem(Convert.ToString(objDAL.DataReader["CompetencyCode"]),
Convert.ToString(objDAL.DataReader["CompetencyID"])));
ddlCompetency.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencyID"])));
}
}
}
else if ((ddlCategory.SelectedValue != null) &&
(ddlCategory.SelectedValue != "0"))
{
using (DataAccessLayer objDAL = new
DataAccessLayer("Competency_GetByCategoryIDAndYear"))
{
SqlParameter sqlparam = new SqlParameter("@catid", SqlDbType.Int);
sqlparam.Value = ddlCategory.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.AddParameter("year", ddlYear.SelectedValue);
objDAL.ExecuteReader();
while (objDAL.DataReader.Read())
{
ddlCompetencyCode.Items.Add(new
ListItem(Convert.ToString(objDAL.DataReader["CompetencyCode"]),
Convert.ToString(objDAL.DataReader["CompetencyID"])));
ddlCompetency.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencyID"])));
}
}
}
else
{
using (DataAccessLayer objDAL = new
DataAccessLayer("Competency_GetAllByYear"))
{
objDAL.AddParameter("year", ddlYear.SelectedValue);
objDAL.ExecuteReader();
while (objDAL.DataReader.Read())
{
ddlCompetencyCode.Items.Add(new
ListItem(Convert.ToString(objDAL.DataReader["CompetencyCode"]),
Convert.ToString(objDAL.DataReader["CompetencyID"])));
ddlCompetency.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencyID"])));
}
}
}
}
else if (ddlCompetencyModel.SelectedIndex > 0)
{
if ((ddlSubCategory.SelectedValue != null) &&
(ddlSubCategory.SelectedValue != "0"))
{
using (DataAccessLayer objDAL = new
DataAccessLayer("Competency_GetBySubCatIDModelYear"))
{
SqlParameter sqlparam = new SqlParameter("@subcat", SqlDbType.Int);
sqlparam.Value = ddlSubCategory.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.AddParameter("year", ddlYear.SelectedValue);
sqlparam = new SqlParameter("@compmodelid", SqlDbType.Int);
sqlparam.Value = ddlCompetencyModel.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.ExecuteReader();
while (objDAL.DataReader.Read())
{
ddlCompetencyCode.Items.Add(new
ListItem(Convert.ToString(objDAL.DataReader["CompetencyCode"]),
Convert.ToString(objDAL.DataReader["CompetencyID"])));
ddlCompetency.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencyID"])));
}
}
}
else if ((ddlCategory.SelectedValue != null) &&
(ddlCategory.SelectedValue != "0"))
{
using (DataAccessLayer objDAL = new
DataAccessLayer("Competency_GetByCatIDModelYear"))
{
SqlParameter sqlparam = new SqlParameter("@catid", SqlDbType.Int);
sqlparam.Value = ddlCategory.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.AddParameter("year", ddlYear.SelectedValue);
sqlparam = new SqlParameter("@compmodelid", SqlDbType.Int);
sqlparam.Value = ddlCompetencyModel.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.ExecuteReader();
while (objDAL.DataReader.Read())
{
ddlCompetencyCode.Items.Add(new
ListItem(Convert.ToString(objDAL.DataReader["CompetencyCode"]),
Convert.ToString(objDAL.DataReader["CompetencyID"])));
ddlCompetency.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencyID"])));
}
}
}
else
{
using (DataAccessLayer objDAL = new
DataAccessLayer("Competency_GetAllByModelYear"))
{
objDAL.AddParameter("year", ddlYear.SelectedValue);
SqlParameter sqlparam = new SqlParameter("@compmodelid",
SqlDbType.Int);
sqlparam.Value = ddlCompetencyModel.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.ExecuteReader();
while (objDAL.DataReader.Read())
{
ddlCompetencyCode.Items.Add(new
ListItem(Convert.ToString(objDAL.DataReader["CompetencyCode"]),
Convert.ToString(objDAL.DataReader["CompetencyID"])));
ddlCompetency.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencyID"])));
}
}
}
}
}
catch
{
ddlCompetencyCode.Items.Clear();
ddlCompetency.Items.Clear();
ddlCompetencyCode.Items.Add(new ListItem("-- select code --", "0"));
ddlCompetency.Items.Add(new ListItem("-- select competency --", "0"));
}
}
else
{
ddlCompetencyCode.Items.Clear();
ddlCompetency.Items.Clear();
ddlCompetencyCode.Items.Add(new ListItem("-- select code --", "0"));
ddlCompetency.Items.Add(new ListItem("-- select competency --", "0"));
}
}
private void FillSubCategoryList()
{
try
{
if ((ddlCategory.SelectedValue != null) && (ddlCategory.SelectedValue !=
"0"))
{
using (DataAccessLayer objDAL = new
DataAccessLayer("CompetencySubCategory_GetByCategoryID"))
{
SqlParameter sqlparam = new SqlParameter("@CatID", SqlDbType.Int);
sqlparam.Value = ddlCategory.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.ExecuteReader();
ddlSubCategory.Items.Clear();
ddlSubCategory.Items.Add(new ListItem("-- select subcategory --", "0"));
if (ddlCompetencyModel.SelectedIndex != 0)
{
while (objDAL.DataReader.Read())
{
ddlSubCategory.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencySubCategoryID"])));
}
}
}
}
else
{
using (DataAccessLayer objDAL = new
DataAccessLayer("CompetencySubCategory_GetAll"))
{
objDAL.ExecuteReader();
ddlSubCategory.Items.Clear();
ddlSubCategory.Items.Add(new ListItem("-- select subcategory --", "0"));
if (ddlCompetencyModel.SelectedIndex != 0)
{
while (objDAL.DataReader.Read())
{
ddlSubCategory.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencySubCategoryID"])));
}
}
}
}
if (ViewState["ddlSubCategory"] != null && ddlSubCategory.Items.Count > 1)
{
ddlSubCategory.SelectedValue = ViewState["ddlSubCategory"].ToString();
ddlSubCategory.SelectedIndex =
ddlSubCategory.Items.IndexOf(ddlSubCategory.Items.FindByValue(ViewState["ddlSubCategory"].ToString()));
}
}
catch
{
ddlSubCategory.Items.Clear();
}
}
Trouble in retaining values of dropdownlist, textboxes, and other
controls when
dropdownlist selectedindexchanged event is triggered, the controls are
inside a user control and this user control inside a parent user control with
an update panel. Can you guys help me hwo to retain the values. I have set
EnableViewState to true. Where is correct page event to store entered and
selected values before the values on controls are re-intialized.
Some of the codes:
protected override void OnLoad(EventArgs e)
{
....
this.UpdateContent();
base.OnLoad(e);
if (multiView.GetActiveView().ID == "viewInputForm")
{
if (Session["id"] != null)
ShowAssessmentDetails(Session["id"].ToString());
DisplayProcessedIconImage();
}
}
//All Dropdown SelectedIndexChanged Event
protected void DropDown_SelectedIndexChanged(object sender, EventArgs e)
{
if (sender == this.ddlEmployee)
{
...
}
else if (sender == this.ddlCategory)
{
FillSubCategoryList();
FillCompetencyList();
}
else if (sender == this.ddlSubCategory)
{
if (ddlSubCategory.SelectedIndex != 0)
{
int subcat = Int32.Parse(ddlSubCategory.SelectedValue);
ddlCategory.SelectedValue = oAssessment.GetCategoryID(subcat);
FillSubCategoryList();
ddlSubCategory.SelectedValue = subcat.ToString();
if (subcat.ToString() != string.Empty && subcat.ToString() != "0")
ViewState["ddlSubCategory"] = subcat.ToString();
}
FillCompetencyList();
}
else if (sender == this.ddlCompetencyCode)
{
UpdateCompetencyList(1);
DoCourseCodeMatching();
}
else if (sender == this.ddlCompetency)
{
UpdateCompetencyList(2);
DoCourseCodeMatching();
}
else if (sender == this.ddlCourseCode)
{
ClearSuggestedTrainingData();
//FillTrainingData();
DoCourseCodeMatching();
}
else if (sender == this.ddlYear)
{
...
}
else if (sender == this.ddlCompetencyModel)
{
FillCategoryList();
FillSubCategoryList();
FillCompetencyList();
}
...
}
private void ShowAssessmentDetails(string idVal)
{
oAssessment.ID = Convert.ToInt32(idVal);
if (oAssessment.Get())
{
InitializeControls();
...
FillCompetencyModelList();//First Dropdown
....
FillEmployeeData();
try { ddlCompetencyModel.SelectedValue =
oAssessment.CompetencyModelID.ToString(); }
catch { ddlCompetencyModel.SelectedIndex = 0; }
FillCategoryList();//Second DropDown
FillSubCategoryList();//Third Dropdown
FillCompetencyList();//Fourth Dropdown
FillCourseCode();
ddlCompetency.SelectedValue = oAssessment.CompetencyID.ToString();
UpdateCompetencyList(2);
try { ddlCourseCode.SelectedValue =
oAssessment.CatalogueCourseID.ToString(); }
catch { ddlCourseCode.SelectedIndex = 0; }
....
FillSupervisorApproval(cbTrainingRequest.Checked);
FillLocalApproval(cbTrainingRequest.Checked);
ddlCSApproval.SelectedValue =
oAssessment.CompetencySupervisorApprovalID.ToString();
ddlCLApproval.SelectedValue =
oAssessment.CompetencyLocalApprovalID.ToString();
....
try { ddlSuggLocalTrainingType.SelectedValue =
oAssessment.SuggestedLocalTrainingType.ToString(); }
catch { ddlSuggLocalTrainingType.SelectedIndex = 0; }
tbLocalTrainingSuggest.Text = oAssessment.SuggestedLocalTraining;
try
{
ddlSuggTrainingType.SelectedValue =
oAssessment.SuggestedTrainingType.ToString();
tbSuggestedTraining.Text = oAssessment.SuggestedTraining;
}
catch
{
ddlSuggTrainingType.SelectedIndex = 0;
tbSuggestedTraining.Text = String.Empty;
}
....
}
}
private void InitializeControls()
{
...
FillCompetencyModelList();
...
FillCategoryList();
FillSubCategoryList();
FillCompetencyList();
FillSupervisorApproval(false);
FillLocalApproval(false);
...
FillCourseCode();
...
}
private void FillCompetencyModelList()
{
try
{
using (DataAccessLayer objDAL = new
DataAccessLayer("CompetencyModel_GetAllByYear"))
{
objDAL.AddParameter("Year", ddlYear.SelectedValue);
objDAL.ExecuteReader();
ddlCompetencyModel.Items.Clear();
ddlCompetencyModel.Items.Add(new ListItem("-- select model --", "0"));
while (objDAL.DataReader.Read())
{
ddlCompetencyModel.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencyModelID"])));
}
}
}
catch
{
ddlCompetencyModel.Items.Clear();
ddlCompetencyModel.Items.Add(new ListItem("-- select model --", "0"));
}
}
private void FillCompetencyList()
{
if (ddlCompetencyModel.SelectedIndex != 0)
{
try
{
ddlCompetencyCode.Items.Clear();
ddlCompetency.Items.Clear();
ddlCompetencyCode.Items.Add(new ListItem("-- select code --", "0"));
ddlCompetency.Items.Add(new ListItem("-- select competency --", "0"));
if (ddlCompetencyModel.SelectedIndex == 0)
{
if ((ddlSubCategory.SelectedValue != null) &&
(ddlSubCategory.SelectedValue != "0"))
{
using (DataAccessLayer objDAL = new
DataAccessLayer("Competency_GetBySubCategoryIDAndYear"))
{
SqlParameter sqlparam = new SqlParameter("@subcat", SqlDbType.Int);
sqlparam.Value = ddlSubCategory.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.AddParameter("year", ddlYear.SelectedValue);
objDAL.ExecuteReader();
while (objDAL.DataReader.Read())
{
ddlCompetencyCode.Items.Add(new
ListItem(Convert.ToString(objDAL.DataReader["CompetencyCode"]),
Convert.ToString(objDAL.DataReader["CompetencyID"])));
ddlCompetency.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencyID"])));
}
}
}
else if ((ddlCategory.SelectedValue != null) &&
(ddlCategory.SelectedValue != "0"))
{
using (DataAccessLayer objDAL = new
DataAccessLayer("Competency_GetByCategoryIDAndYear"))
{
SqlParameter sqlparam = new SqlParameter("@catid", SqlDbType.Int);
sqlparam.Value = ddlCategory.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.AddParameter("year", ddlYear.SelectedValue);
objDAL.ExecuteReader();
while (objDAL.DataReader.Read())
{
ddlCompetencyCode.Items.Add(new
ListItem(Convert.ToString(objDAL.DataReader["CompetencyCode"]),
Convert.ToString(objDAL.DataReader["CompetencyID"])));
ddlCompetency.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencyID"])));
}
}
}
else
{
using (DataAccessLayer objDAL = new
DataAccessLayer("Competency_GetAllByYear"))
{
objDAL.AddParameter("year", ddlYear.SelectedValue);
objDAL.ExecuteReader();
while (objDAL.DataReader.Read())
{
ddlCompetencyCode.Items.Add(new
ListItem(Convert.ToString(objDAL.DataReader["CompetencyCode"]),
Convert.ToString(objDAL.DataReader["CompetencyID"])));
ddlCompetency.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencyID"])));
}
}
}
}
else if (ddlCompetencyModel.SelectedIndex > 0)
{
if ((ddlSubCategory.SelectedValue != null) &&
(ddlSubCategory.SelectedValue != "0"))
{
using (DataAccessLayer objDAL = new
DataAccessLayer("Competency_GetBySubCatIDModelYear"))
{
SqlParameter sqlparam = new SqlParameter("@subcat", SqlDbType.Int);
sqlparam.Value = ddlSubCategory.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.AddParameter("year", ddlYear.SelectedValue);
sqlparam = new SqlParameter("@compmodelid", SqlDbType.Int);
sqlparam.Value = ddlCompetencyModel.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.ExecuteReader();
while (objDAL.DataReader.Read())
{
ddlCompetencyCode.Items.Add(new
ListItem(Convert.ToString(objDAL.DataReader["CompetencyCode"]),
Convert.ToString(objDAL.DataReader["CompetencyID"])));
ddlCompetency.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencyID"])));
}
}
}
else if ((ddlCategory.SelectedValue != null) &&
(ddlCategory.SelectedValue != "0"))
{
using (DataAccessLayer objDAL = new
DataAccessLayer("Competency_GetByCatIDModelYear"))
{
SqlParameter sqlparam = new SqlParameter("@catid", SqlDbType.Int);
sqlparam.Value = ddlCategory.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.AddParameter("year", ddlYear.SelectedValue);
sqlparam = new SqlParameter("@compmodelid", SqlDbType.Int);
sqlparam.Value = ddlCompetencyModel.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.ExecuteReader();
while (objDAL.DataReader.Read())
{
ddlCompetencyCode.Items.Add(new
ListItem(Convert.ToString(objDAL.DataReader["CompetencyCode"]),
Convert.ToString(objDAL.DataReader["CompetencyID"])));
ddlCompetency.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencyID"])));
}
}
}
else
{
using (DataAccessLayer objDAL = new
DataAccessLayer("Competency_GetAllByModelYear"))
{
objDAL.AddParameter("year", ddlYear.SelectedValue);
SqlParameter sqlparam = new SqlParameter("@compmodelid",
SqlDbType.Int);
sqlparam.Value = ddlCompetencyModel.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.ExecuteReader();
while (objDAL.DataReader.Read())
{
ddlCompetencyCode.Items.Add(new
ListItem(Convert.ToString(objDAL.DataReader["CompetencyCode"]),
Convert.ToString(objDAL.DataReader["CompetencyID"])));
ddlCompetency.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencyID"])));
}
}
}
}
}
catch
{
ddlCompetencyCode.Items.Clear();
ddlCompetency.Items.Clear();
ddlCompetencyCode.Items.Add(new ListItem("-- select code --", "0"));
ddlCompetency.Items.Add(new ListItem("-- select competency --", "0"));
}
}
else
{
ddlCompetencyCode.Items.Clear();
ddlCompetency.Items.Clear();
ddlCompetencyCode.Items.Add(new ListItem("-- select code --", "0"));
ddlCompetency.Items.Add(new ListItem("-- select competency --", "0"));
}
}
private void FillSubCategoryList()
{
try
{
if ((ddlCategory.SelectedValue != null) && (ddlCategory.SelectedValue !=
"0"))
{
using (DataAccessLayer objDAL = new
DataAccessLayer("CompetencySubCategory_GetByCategoryID"))
{
SqlParameter sqlparam = new SqlParameter("@CatID", SqlDbType.Int);
sqlparam.Value = ddlCategory.SelectedValue;
objDAL.AddParameter(sqlparam);
objDAL.ExecuteReader();
ddlSubCategory.Items.Clear();
ddlSubCategory.Items.Add(new ListItem("-- select subcategory --", "0"));
if (ddlCompetencyModel.SelectedIndex != 0)
{
while (objDAL.DataReader.Read())
{
ddlSubCategory.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencySubCategoryID"])));
}
}
}
}
else
{
using (DataAccessLayer objDAL = new
DataAccessLayer("CompetencySubCategory_GetAll"))
{
objDAL.ExecuteReader();
ddlSubCategory.Items.Clear();
ddlSubCategory.Items.Add(new ListItem("-- select subcategory --", "0"));
if (ddlCompetencyModel.SelectedIndex != 0)
{
while (objDAL.DataReader.Read())
{
ddlSubCategory.Items.Add(new
ListItem(MultiLanguageField.GetFieldValue(Convert.ToString(objDAL.DataReader["Name"])), Convert.ToString(objDAL.DataReader["CompetencySubCategoryID"])));
}
}
}
}
if (ViewState["ddlSubCategory"] != null && ddlSubCategory.Items.Count > 1)
{
ddlSubCategory.SelectedValue = ViewState["ddlSubCategory"].ToString();
ddlSubCategory.SelectedIndex =
ddlSubCategory.Items.IndexOf(ddlSubCategory.Items.FindByValue(ViewState["ddlSubCategory"].ToString()));
}
}
catch
{
ddlSubCategory.Items.Clear();
}
}