Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using data from SqlDataSource

Status
Not open for further replies.

lumstar

Technical User
Jan 29, 2002
177
CA
Hi There,

I'm trying to put some data from a SQL database directly into my asp page - rather than in a databound control. Is this possible? I thought I could use a literal databinding expression like <%# sqlDataSource.nameOfSelectedItem %> and the text would appear on the page, but first of all I cannot reference selected items like this, and secondly data in the literal does not show up when rendered in a browser.

Anyone know how this can be done and/or what I am doing wring?

Thanks in advance!
Stephen
 
1. datasource controls are ment to be bound to controls, so what you want to do above either will not work, or is more trouble than it's worth.

2. never use datasource controls.
it goes against the separation of concerns principle (an object should have only one reason to change)
you cannot debug (step through) a markup control
you cannot unit test controls on a webform
you have no chance to preform any business logic which may be required.

Instead use a data access layer to write queries and serve the data back to the presentation layer. here are the most prominent frameworks for data access.
NHibernate
ActiveRecord
LLBL Gen Pro 2
Enterprise Library

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top