Data Binding ASP.Net Tutorial

A HyperLinkField is useful when you need to build two page Master/Detail forms.
File: Master.aspx
<%@ Page Language="C#" %>


    Master


    
    

            id="grdProductCategories"
        DataSourceID="srcProductCategories"
        AutoGenerateColumns="false"
        Runat="server">
        
                    HeaderText="Product Categories"
            DataTextField="Name"
            DataNavigateUrlFields="Id"
            DataNavigateUrlFormatString="Details.aspx?id={0}" />
        

    
            id="srcProductCategories"
        ConnectionString="<%$ ConnectionStrings:Products %>"
        SelectCommand="SELECT Id, Name FROM ProductCategories"
        Runat="server" />
    

    


            
File: Details.aspx
<%@ Page Language="C#" %>
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">


    Details


    
    

            id="grdProducts"
        DataSourceID="srcProducts"
        Runat="server" />
            id="srcProducts"
        ConnectionString="<%$ ConnectionStrings:Products %>"
        SelectCommand="SELECT Title,Director FROM Products
            WHERE CategoryId=@CategoryId"
        Runat="server">
        
                    Name="CategoryId"
            QueryStringField="id" />
        

    
    

    


File: Web.config

  
             connectionString="Data Source=.\SQLEXPRESS;
         AttachDbFilename=|DataDirectory|MyDatabase.mdf;Integrated Security=True;User Instance=True" />