< asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="< %$ ConnectionStrings:NorthwindConnectionString %> " SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [Address], [City] FROM [Customers]"> < /asp:SqlDataSource> An entry will be added to the web.config file as shown below: < connectionStrings> < add name="NorthwindConnectionString" connectionString="Data Source=(local);Initial Catalog=Northwind;Integrated Security=True" providerName="System.Data.SqlClient"/> < /connectionStrings>
< asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="CustomerID" DataSourceID="SqlDataSource1" OnRowDataBound="GridView1_RowDataBound" Font-Names="Verdana" Font-Size="Small"> < Columns> < asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID" /> < asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" /> < asp:BoundField DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" /> < asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" /> < asp:BoundField DataField="City" HeaderText="City" SortExpression="City" /> < /Columns> < /asp:GridView>