Binding dataset to a Dropdown list

F

Fraggle_Rock_1

I have a dataset like so

|ID | type | Name
------------------
|1 | 1 | ham
|2 | 2 | fish
|1 | 2 | lard
|2 | 1 | spam


the data is coming from 2 tables in a database being forced into the
same table in the dataset. There are 2 "types" the ID's are autonumbers
in the database, but in the table in the dataset they are not unique.
ID+type would work as a primary Key.

How can i bind this to a dropdown so the user will see (name), the
system will display a different panel based on the Type, and fill the
controls in the panel depending on the ID of the selection (and using
the appropriate sproc for the particular type of the selection.).
Cheers

Frag
 
W

Wasi Rehman

Hi Rock,

Its verty simple

suppose ds is dataset

cbo.DataSource=ds;
cbo.DataTextField="Name";
cbo.DataValueField= "ID";
cbo.DataBind();

for unique id its better to concatenate fields ( ID and type) in your sql
query for better result.

Regards,
Wasi Ur Rehman
 
F

Fraggle

Wasi Rehman said:
Hi Rock,

Its verty simple

suppose ds is dataset

cbo.DataSource=ds;
cbo.DataTextField="Name";
cbo.DataValueField= "ID";
cbo.DataBind();

If I do this then what happens when I select "Spam" from the drop
down? I my ID would be "2" the same as the ID for "fish".
What I need to be able to get is select "spam" and get ID=2 type=1,
which is unique. The reason that ID is not a unique thing is because
the dataset is compiled from a number of database tables.

Probably in an ideal world I would do things different, however the
world is not ideal!

Thanks for your time though!

Fragg
 

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,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top