sql data source in asp.net

  • Thread starter Thread starter Claudia Fong
  • Start date Start date
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
 
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
 
Back
Top