sql data source in asp.net

C

Claudia Fong

Hi

I have a sql data source which selects 2 fields from my table (name and
id). The name will be display in the dropdown list; I want to store the
value of the id in a variable.. how can I do that? I used to do it with
an object data reader.. but I think I can do it an easier way with the
sql data source?

Can someone tell me how?

Cheers!

Claudi
 
D

David Wier

Just use the DataTextField (in the ddl) for the name, and use the
DataValueField (in the DDL) for the id
then, whatever you choose in the Dropdownlist, you can use either
DDL.SelectedItem.Text
or
DDL.SelectedItem.Value (id)


David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
 

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

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top