Drop down lists
-
I've got two drop down lists on a page, both connected to a separate sql datasource. The first drop down list is a list of States in the database, the second is a list of political offices that fall under the oversight of the state selected in the first box. If I select a state first, the second drop down list will populate just fine, but if I select another state, the values for the offices of the new state are appended to the bottom of the list after the offices of the first state. Now, I got the appenddatabounditems set to true so that I can have a "Select" statement at the top of the list if there isn't anything selected. Is this the problem, and if so is there a work around for this?
-
I've got two drop down lists on a page, both connected to a separate sql datasource. The first drop down list is a list of States in the database, the second is a list of political offices that fall under the oversight of the state selected in the first box. If I select a state first, the second drop down list will populate just fine, but if I select another state, the values for the offices of the new state are appended to the bottom of the list after the offices of the first state. Now, I got the appenddatabounditems set to true so that I can have a "Select" statement at the top of the list if there isn't anything selected. Is this the problem, and if so is there a work around for this?
I usually create a dummy item for the select and then append it to the top of my datasource. Personally I don't like data binding so would rather populate the list with the associated loop instead making it more obvious what is going on and giving this level of control more naturally. Either flavor will work in your situation ... one more suggestion is to use Javascript for the entire procedure instead of postbacks or ajax which really works well for small lists.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego. -
I've got two drop down lists on a page, both connected to a separate sql datasource. The first drop down list is a list of States in the database, the second is a list of political offices that fall under the oversight of the state selected in the first box. If I select a state first, the second drop down list will populate just fine, but if I select another state, the values for the offices of the new state are appended to the bottom of the list after the offices of the first state. Now, I got the appenddatabounditems set to true so that I can have a "Select" statement at the top of the list if there isn't anything selected. Is this the problem, and if so is there a work around for this?
Hi First time it comming fine because it's clear so now In the SelectedIndex_Changed event DropDownLost1.Clear(); Code to bind data to DropDownList Then DropDownList1.Items.InsertAt(0,"Select"); I think it will solve your problem Techie From Surat http://techiefromsurat.blogspot.com/