[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Drop down list need help

Posted on 2005-05-11
5
Medium Priority
?
213 Views
Last Modified: 2010-04-07
I have an <ASP:dropdownlist> with 10 values (not from the DB), but in my DB I have a value that relate to the dropdownlist. How can I get the dropdownlist match the values from my db?

0
Comment
Question by:Ennio
5 Comments
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 13981606
How are the DB and DDL values related?
0
 
LVL 6

Expert Comment

by:dharmesh_amity
ID: 13981618
Not sure what you want. Why don't you populate the dropdown from the db, so that it will match the values in db?
0
 
LVL 9

Accepted Solution

by:
stengelj earned 600 total points
ID: 13981862
How about something like this...

Sub Page_Load(Src As Object, E As EventArgs)

    'Connect to the database...
    Dim myDataset as Dataset
        'Create the dataset...
    Dim myValue = myDataset.Tables(0).Rows(0).Item("myItemValue")
        ' Here's where we set the Selected Item to the DB value
        ddl_MyDropDownList.SelectedIndex = ddl_MyDropDownList.Items.IndexOf(ddl_MyDropDownList..Items.FindByValue(myValue))

End Sub
0
 
LVL 1

Author Comment

by:Ennio
ID: 13982548
I added to the DB and I can display fine.... thnks

Now, can I populate more then 1 dropdown at the same time with the same dataset? or I need to have one fore each one?
0
 
LVL 24

Assisted Solution

by:Jeff Certain
Jeff Certain earned 800 total points
ID: 13982588
Same dataset or datatable? You can populate with either. When you use a dataset, the DDL assumes table(0).

You can do this to populate multiple DDL form teh same dataset, same table:
ddl1.DataSource=ds
ddl1.DataBind
ddl2.DataSource=ds
ddl2.DataBind

Same DS, different tables (you can reference them by index or name):
ddl1.DataSource=ds.Tables(0)
ddl1.DataBind
ddl2.DataSource=ds.Tables("Table1")
ddl2.DataBind
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question