Dropdown Box troubles


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Dropdown Box troubles

  1. #1
    Join Date
    May 2005
    Posts
    3

    Dropdown Box troubles

    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!

  2. #2
    Join Date
    May 2005
    Posts
    3
    i fixed it! It was posting fine, just somewhere it wasbeing changed, so i just set the selected item to Request["OfficeInputSecond"] and it worked! yay!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center