Hello - I have created a page for Editing records. this page will open up a chosen record and allow user to edit the data.On the form, I have 3 drop down lists. The second dropdown list should fill values depending on value chosen in first dropdown list. The third dropdown list should show/fill values depending on value chosen in second dropdown list.So taking this into count, i have several records with various data. When I open-up/load a record in Edit form, only the first dropdown list has a value selected that was the pre-existing value entered in database. The last two dropdowns are populated but the previously chosen values are not selected. The last 2 dropdown lists show up as blank even when I had selected some values when creating the record.I know this may sound a little confusing but please let me know if you have any questions.Please Help!!Thank you!!!!!
![]() |
0 |
![]() |
Can you post the code snippet that populates the dropdownlists on load of the page?
Sambeet
![]() |
0 |
![]() |
hi Sambeetpatra . Thank you for getting back so quickly. - Here's the page load event, where i populate controls:
private void Page_Load(object sender, System.EventArgs e){
if (Page.IsPostBack == false){
string isID = Request.QueryString["Issueid"];int ISID = Convert.ToInt32(isID); string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~\\App_Data") + "\\ISSUELOG.mdb";OleDbConnection cn = new OleDbConnection(connectString); //Open the connection.cn.Open();
string selectString = "SELECT * FROM IssueRecordTable where IssueID=" + ISID; OleDbCommand cmd = new OleDbCommand(selectString, cn);OleDbDataReader reader = cmd.ExecuteReader();while (reader.Read()){
IssueIDLabel.Text = reader["IssueID"].ToString();
JobNumbertxt.Text = reader[
"JobNumber"].ToString();JobProgrammedbyddl.SelectedValue = reader["JobProgrammedby"].ToString();VendorProgtxt.Text = reader[
"VendorProgName"].ToString();Statuslbl.Text = reader["Status"].ToString();DateOfIssuetxt.Value = reader[
"DateofIssue"].ToString();IssEnteredByddl.SelectedValue = reader["IssEnteredBy"].ToString();ReportSourceddl.SelectedValue = reader[
"ReportSource"].ToString();ReporterNametxt.Text = reader["ReporterName"].ToString();IssueCategoryddl.SelectedValue = reader[
"IssueCategory"].ToString();IssueCategory2ddl.SelectedValue = reader["IssueDetailCombobox"].ToString();IssueCategory3ddl.SelectedValue = reader[
"IssueDetail2opts"].ToString();OverUnderLabel.Text = reader["QuotaOU"].ToString();EstimatedDateTxt.Value = reader[
"EstimatedDate"].ToString();ActualDateTxt.Value = reader["ActualDate"].ToString();EstdTimeTxt.Text = reader[
"EstimatedTime"].ToString();ActualTimeTxt.Text = reader["ActualTime"].ToString();TimeLateTxt.Text = reader[
"TimeLate"].ToString();NumMinsAwayTxt.Text = reader["IssueDetail3txt"].ToString();SeverityLevelddl.SelectedValue = reader[
"SeverityLevel"].ToString();StdGuidVioddl.SelectedValue = reader["StnGdlViolated"].ToString();RespforErrorLabel.Text = reader[
"CausedError"].ToString();ProgDollarAmounttxt.Text = reader["ProgrammingDollarAmount"].ToString();DataConDollarAmounttxt.Text = reader[
"DataConDollarAmount"].ToString();QADollarAmounttxt.Text = reader["QADollarAmount"].ToString();RespondentsAffectedtxt.Text = reader[
"RespondentsAffected"].ToString();EscalatedTotxt.Text = reader["EscalatedTo"].ToString();QAedddl.SelectedValue = reader[
"QAed"].ToString();QAedbyLabel.Text = reader["WhoQAed"].ToString();WhatHappenedtxt.Text = reader[
"WhatHappened"].ToString();WhyDidItHappentxt.Text = reader["WhyDidItHappen"].ToString();ActionTakentxt.Text = reader[
"ActionTaken"].ToString();HowtoPreventtxt.Text = reader["HowtoPrevent"].ToString();CostDescriptiontxt.Text = reader[
"CostDescription"].ToString();Summarytxt.Text = reader["Summary"].ToString();ClosedDatetxt.Value = reader[
"ClosedDate"].ToString();IssueClosedByddl.SelectedValue = reader["ClosedUser"].ToString();}
reader.Close();
cn.Close();
if (ClosedDatetxt.Value == null || ClosedDatetxt.Value == ""){
Statuslbl.Text = "Open";}
else{
Statuslbl.Text = "Closed";}
MultiViewRBL.SelectedIndex = 0;
}
}
![]() |
0 |
![]() |
Also forgot to mention: the dropdown list 1, 2, and 3 are respectively:
IssueCategoryddl.SelectedValue = reader["IssueCategory"].ToString();IssueCategory2ddl.SelectedValue = reader[
"IssueDetailCombobox"].ToString();IssueCategory3ddl.SelectedValue = reader[
"IssueDetail2opts"].ToString();
![]() |
0 |
![]() |
Ok, this may be conflicting with your logic to keep DDL2 empty till a selction is made in DDL1 and keep DDL3 empty till a selection is made in DDL2. Even if you assign the selected value, it does not necessarily fire the selected event for the DDL. Assuming that you have implemented events for selectedIndexChanged for the dropdownlists, Try doing this:
IssueCategoryddl.SelectedValue = reader["IssueCategory"].ToString();
//here call the function that handles selectedIndexChanged event for IssueCategoryddl, i.e. IssueCategoryddl_SelectedIndexChanged(IssueCategoryddl, new EventArgs());
//this will at least fill up the second dropdown prior to setting the selected value
IssueCategory2ddl.SelectedValue = reader["IssueDetailCombobox"].ToString();
//here call the function that handles selectedIndexChanged event for IssueCategory2ddl, i.e. IssueCategory2ddl_SelectedIndexChanged(IssueCategory2ddl, new EventArgs());
IssueCategory3ddl.SelectedValue = reader["IssueDetail2opts"].ToString();
Sambeet
![]() |
0 |
![]() |