Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DropDownList control and setting selected 2

Status
Not open for further replies.

jkb17

Programmer
Nov 27, 2000
156
US
Hello.

I have created a data-bounded drop down list (combo box) on an ASP.NET page.

The displayed text of each list item in the comb box comes from a field from a table. The value of the list item relates to the ID of the related field. The IDs should be near sequential but not necessarily.

when I make a selection on a page I can catch the selected VALUE. I would need to re-populate another instance of the same combo-box on the new page and I would like to preserve the already selected item from the previous page.

How do I do this? It seems that if the ID\value happens to be 20 and there are only 3 items it will reference the INDEX of the combo-box and not the value. I need to match them up based on value.

Any tips?

Thank you in advance.
 
So if I catch this right you have already been able to send the value across?

Make sure the new drop down is filled.
Next just use the following code in your page load event replacing value with your incoming value variable

if not ispostback then
dropdown1.Items.findbyvalue(value).selected = true
end if


I hope that is what you were asking. That'l do donkey, that'l do
[bravo] Mark
 
You the man, Zarcom/Mark. Thanks a lot.

I've caught up and pretty much up to speed with a lot of this dotNET stuff. Its just those little things that cause a setback for me and then I have to file through docs and help files (or rummage through the intellisense and check every possible object and method). I can spend hours searching for the simple solution....good thing: i get exposed to a lot of other functionality during the hunt; bad thing: i spent most of my day trying to select a specific value in a pre-loaded ComboBox!

Appreciate it!!

Jim
 
I know what your saying. It's often the simple things that take the longest. If you want check out our Tidbits thread. There is some goodies in there.
thread855-288280

Thanks for the star. That'l do donkey, that'l do
[bravo] Mark
 
You're welcome for the star! It was helpful and spared me the search time and the hunt.

Those pages are done and now I have my code template to tackle the next set!

Thanks again and thanks for the thread.

bye
jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top