Databinding Dropdownlist to Main Dataset

J

jdsharp

I understand how to bind the Dropdownlist control to a table so that it
shows the list of values, but how do I bind it to my main data entry
dataset?

Thanks for the help!
Jason
 
G

Guest

When you databind a dataset to a dropdownlist or any other bindable control
for that matter, it gets bound to the FIRST table in the dataset.

In order to bind it to any other tables in the dataset you will need to
reference them specifically and bind the actual table to it.

The dropdownlist datasource property will take a dataset as its source just
the same as the datatable.
 
D

Dhanushka Nuwan

dropdownlist1.DataSource = ds;
dropdownlist1.DataMember = ds.Tables[0].TableName;
dropdownlist1.DataTextField = "NAME";
dropdownlist1.DataValueField = "ID";
dropdownlist1.DataBind();

Cheers,

Dhanushka Nuwan
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top