6.2. Using the SqlDataSource Control
The SQLDataSource control is a user-friendly way of working with Microsoft's ADO.NET data handling technology. It does much of the grunt work for you, such as opening a connection to the database, executing a SQL statement, fetching the data, and closing the data connection.
6.2.1. Adding and configuring a SqlDataSource control
You need a working SqlDataSource control so that other controls, such as GridView, FormView, and ListView, can use it for their data needs. To add a SqlDataSource control to your page, follow these steps:
Add a single file ASP.NET Web Form (don't use the Place Code in Separate File option) called starter.aspx to your project.
Drag a SqlDataSource control from the Data category of the Toolbox and drop it on the page.
Click the Smart Tag button and select Configure Data Source.
The Configure Data Source Wizard appears.
From the drop-down list, choose the northwnd.mdf data connection and then click Next.
Accept (that is, leave checked) the offer to save the connection string in the Save the Connection String screen, and then click Next.
In the Configure the Select Statement dialog box, choose the Customers table from the drop-down list.
The columns (fields) in the Customers table appear in the Columns box.
In the Columns box, select the check box for the asterisk.
This indicates that you want to select all the columns for the query.
Click the Advanced button.
The Advanced SQL Generation Options dialog box appears, as shown in Figure ...
Get ASP.NET 3.5 For Dummies® now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.