how to bind values from database to gridview?
<p>I am very new to asp.net.Plz help me. </p>

<p>I have a gridview with two columns named-property(template field) and value(template field). I need to bind the property column(ie,gridview- item template(label)) from database table 'properties'.Properties table fields are ID and PropertyName. How can I bind them??</p>

<pre><code> protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindView();


            }

                DataTable dt1 = new DataTable();
                SqlDataAdapter da1 = new SqlDataAdapter("select ID,TypeName from ProductTypes", con);
                da1.Fill(dt1);
                DropDownList1.DataSource = dt1;
                DropDownList1.DataValueField = "ID";
                DropDownList1.DataTextField = "TypeName";
                DropDownList1.DataBind();
            }

        public void BindView()
        {

            DataTable dt = new DataTable();
            string sql = "select * from Properties";
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter(sql, con);
            da.Fill(dt);
            GridView1.DataSource = dt;
            GridView1.DataBind();
            con.Close();
        }
</code></pre>

<p>aspx code:</p>

<pre><code> asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" 
    CellPadding="3" GridLines="Horizontal" 
    style="z-index: 1; left: 52px; top: 230px; position: absolute; height: 133px; width: 344px"&gt;
    &lt;RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" /&gt;
    &lt;Columns&gt;
        &lt;asp:TemplateField&gt;&lt;/asp:TemplateField&gt;
        &lt;asp:TemplateField HeaderText="Property"&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:Label ID="Label3" runat="server" Text='&lt;%# Eval("PropertyName") %&gt;' &gt;&lt;/asp:Label&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;
        &lt;asp:TemplateField HeaderText="Value"&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:TextBox ID="TextBox2" runat="server"&gt;&lt;/asp:TextBox&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;
    &lt;/Columns&gt;
    &lt;FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /&gt;
    &lt;PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" /&gt;
    &lt;SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" /&gt;
    &lt;HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" /&gt;
    &lt;AlternatingRowStyle BackColor="#F7F7F7" /&gt;
&lt;/asp:GridView&gt;
</code></pre>
