473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

sql data source in asp.net

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

*** Sent via Developersdex http://www.developersdex.com ***
Oct 1 '07 #1
1 1082
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
"Claudia Fong" <cd********@yahoo.co.ukwrote in message
news:O$**************@TK2MSFTNGP04.phx.gbl...
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

*** Sent via Developersdex http://www.developersdex.com ***

Oct 1 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Monica Ferrero | last post by:
Hi! I'm not sure if this is the most adequate mySQL list for this post. If not, please indicat me which one I should use... I'm using Tomcat 4.1.24 with Apache 2 and MySQL 4.0.13. I have the...
2
by: Greg Strong | last post by:
Hello All, I've written code in a test database with test data. Everything seems to be working except compact database in VB code per http://www.mvps.org/access/general/gen0041.htm. The reason I...
18
by: xarax | last post by:
Greetings, What is the general practice, usual and customary way, of including a data file into a source file? I have some large data structures defined as source similar to: ...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
5
by: rogsonl | last post by:
My computer was moved last week, and the company changed the network groups we work on. As a result, one of the main benefits from Whidbey (database connectivity) no longer works. Situation: 1....
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
7
by: John J. Hughes II | last post by:
I have a DataGridView with a TextBoxColumn. I setting the data source to a List<stringvalue in a static class. The list is filled from a background thread. So far all is fine and it works...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
0
by: BillE | last post by:
I am using Visual Studio 2005 to create a web site which includes reports. The web site has several sub-folders. When working with reports I can't get the website data sources (classes and...
0
natalie99
by: natalie99 | last post by:
Hey people! Being so lacking in access knowhow I have turned to good old 'asking the smart people' again! I need to create a query or lookup table (although I have had zero success with lookups...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.