Bind to Data Without Writing Code
Most serious web applications need to retrieve records from a database. In .NET, the database access framework of choice is ADO.NET. However, writing the code to perform common database operations with ADO.NET, such as opening a connection and fetching a table of results, can be tedious and repetitive, which is not what VB programmers have come to expect. To simplify such tasks, ASP.NET 2.0 introduces several new data source controls that greatly simplify the task of retrieving data and binding it to a web page.
Note
With the new ASP.NET data provider controls, you can generate and bind all your database code at design time, without writing a single line of code.
How do I do that?
To use a new ASP.NET 2.0 data source control, all you need to do is to drag it from the Visual Studio toolbox to a web page, configure a few of its properties, and then bind it to other controls that display the data it exposes. When you run the web page, the data source control performs the heavy lifting, contacting your database and extracting the rows you need.
ASP.NET ships with several data source controls, and more are planned. Although the list has changed from build to build, the latest release includes:
SqlDataSourceInteracts with a SQL Server database (Version 7.0 or later).
XmlDataSourceInteracts with XML data from a file or some other data source.
ObjectDataSourceInteracts with a custom object that you create. The next lab, "Bind Web Controls to a Custom Class," ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access