ADO Net Database ASP.Net Tutorial

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

    void Page_Load()
    {
        if (Request.Cookies["VoterId"] == null)
        {
            string identifier = Guid.NewGuid().ToString();
            HttpCookie voteCookie = new HttpCookie("VoterId", identifier);
            voteCookie.Expires = DateTime.MaxValue;
            Response.AppendCookie(voteCookie);
        }
    }



    Vote


    
    

            id="frmVote"
        DataSourceID="srcVote"
        DefaultMode="Insert"
        Runat="server">
        
                    id="lblFavoriteColor"
            AssociatedControlID="rdlFavoriteColor"
            Runat="server" />
                    id="rdlFavoriteColor"
            SelectedValue='<%#Bind("Color")%>'
            Runat="server">
           
           
           
        
        
                   id="btnSubmit"
           Text="Submit"
           CommandName="Insert"
           Runat="server" />
        

    
    
            id="grdVote"
        DataSourceID="srcVote"
        Runat="server" />
            id="srcVote"
        SelectCommand="SELECT * FROM Vote
            ORDER BY Id DESC"
        InsertCommand="INSERT Vote (VoterId,Color)
            VALUES (@VoterId,@Color)"
        ConnectionString="<%$ ConnectionStrings:Vote %>"
        Runat="server">
        
                            CookieName="VoterId" />
                

    
    

    


File: Web.config

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