Database Reference
In-Depth Information
Connecting a GridView to SQL Azure
Continue the example by following these steps:
1.
Add a
GridView
control on the
Default.aspx
page, and connect it to a SQL
Azure database. Although SqlDataSource is compatible with SQL Azure, it isn't
possible to add a SqlDataSource and configure it with the built-in wizard;
these steps next show you how to configure the SqlDataSource manually.
Open the
Default.aspx
page, and select Design view.
2.
Drag a
SqlDataSource
from the Toolbox. Drag a
GridView
control on the page
as well, and set its Data Source property to
SqlDataSource1
, as shown in Figure
9-13.
3.
Figure 9-13.
Changing the
GridView
's Data Source property
Open the
web.config
file, and enter your connection string. (Chapter 3
explains how to retrieve your connection string from the Azure Portal.) You
need to add a
connectionStrings
node under the
configuration
node, as
shown in the following example:
4.