ASP.NET  •  Hook Up Data

Listing 2. You associate data-display controls, such as the new GridView control, by using an attribute named DataSourceID. When the page first loads, the data source control is invoked, and the returned data is bound to the GridView server control.

<asp:gridview id="GridView1" runat="server"
   datasourceid="SqlDataSource1">
</asp:gridview>

<asp:sqldatasource id="SqlDataSource1" 
   runat="server"
   selectcommand="SELECT Customers.* FROM 
   Customers WHERE customerID = ?"
   providername="System.Data.OleDb" 
   connectionstring="(removed for brevity)">
   <selectparameters>
      <asp:querystringparameter name="CustomerID" 
         querystringfield="CustID" 
         type="String">
      </asp:querystringparameter>
   </selectparameters>
</asp:sqldatasource>