1
Reply

Dropdown Box troubles

joe_coolish

joe_coolish

May 26 2005 12:50 PM
2.5k
ok, here's what i've got. I have this internal phonedirectory page that i'm developing, and one of the options (to select the office) is done with a dropdown box, and when an office is selected that has sub offices, a second dropdown box's visibility is set to true so that you can select from that DDB to. Now, i'm querying all the data for the second dropdown box from a SQL database (i'm probably going to convert the first drop down to be pulled from a db soon) but the problem comes when i do a submit on the form. All the data stays, but the second ddb resets the select to the defualt (top) item. The second drop down box initially has no items and the script that adds data to the box is as follows . . . if(OfficeInput.SelectedValue.Equals("") { . . . } else { . . OfficeInputSecond.Items.Clear(); phoneConn.Open(); SqlDataReader read = phoneComm.ExecuteReader(); while(read.Read()) { if(read[0].ToString().Equals(OfficeInput.SelectedValue)) { if(OfficeInputSecond.Items.Count>0) { OfficeInputSecond.Items.Add(read[1].ToString()); } else { OfficeInputSecond.Items.Add(""); OfficeInputSecond.Items.Add(read[1].ToString()); } } } phoneConn.Close(); . . } So, is it a postback issue? or how can i force the drop down to not change on submit? thanks!

Answers (1)