Click here to Skip to main content
15,917,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Anyone know to fill dropdown list value from web.config if i have few dropdownlist which all is related? eg: if i select ddlA, then ddlB will give me the value base on ddlA, same as ddlC and ddlD..?

Currently i only know how to fill it all in the dropdownlist as below, but what I ready need is;
when user select Gre -> I will only show A,B,C in the ddl2;
when user select Phi-> I need to show D,E,F in ddl2 only.
Hope someone can give me more detail step in vb


<add key="Value1" value="Gre, Phi" />
    <add key="Value2" value="A,B C,D E,F" />
    <add key="Value3" value="..." />
Posted
Updated 18-Jul-12 17:27pm
v2

I am not sure why you want to use the web.config but you CAN store an XML value as a string, and pars that XML to get your drop down list values. If it's not heirarchical ( as your post seems to imply ) then you could use a CSV, you can't just store values b/c there's an indeterminate number and it will get ugly. Personally, I'd store them in a file in app_data and read that, instead, if you must configure the content from a file on your web server and not from a database ( my first choice )
 
Share this answer
 
You can use a set of cascading dropdowns.
These links are in C#, but you can try and convert this code to VB.Net -
http://csharpdotnetfreak.blogspot.in/2009/03/populate-dropdown-based-selection-other.html[^]
 
Share this answer
 
Comments
happy_123 20-Jul-12 2:34am    
I not using database, so is there any sample i can set the value in web.config and control there? Thanks
try this one.
VB
Dim strPwd As String
Dim i As Integer

strPwd = ConfigurationManager.AppSettings("Value1")

Dim arrPwd = Split(strPwd, ", ")

For i = 0 To UBound(arrPwd)
    ddlValue1.items.add(arrPwd(i))
Next
 
Share this answer
 
Comments
happy_123 20-Jul-12 2:20am    
hi, this is what i currently doing.
what i need is when user select Gre from ddl1, ddl2 will only show A,B,C;
then when user select Phi from ddl1, dd2 will only show D,E,F.
graciax8 20-Jul-12 3:30am    
where will the user select Gre or Phi?
happy_123 22-Jul-12 20:21pm    
Gre or Phi is in the 1st dropdown list; after user select that, value in 2nd dropdown list, will display according to the 1st selection.
graciax8 22-Jul-12 21:25pm    
well then place this code on the 1st dropdown,

strPwd = ConfigurationManager.AppSettings("Value1")

and depending on the selected value of the user, fill the 2nd dropdown.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900