title: Insert values to database table using textbox in gridview
body: <p>I have a grid view with two columns. One named <strong>product</strong> and the other named <strong>values</strong> (both columns in template field).  </p>
  
  <p>The <strong>product</strong> column is bound to the "product" table. And the <strong>value</strong> field's item template contains a textbox. </p>
  
  <p>I need to insert the values into database table "BrandProperties" through textbox in grid view, but I am not sure how to do this.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    if (!IsPostBack)
      {
          BindView();
  
      }
  
      DataTable dt = new DataTable();
      SqlDataAdapter da = new SqlDataAdapter("select ID,TypeName from ProductTypes",con);
      da.Fill(dt);
      DropDownList1.DataSource = dt;
      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>   Text="Brand Name"&gt;&lt;/asp:Label&gt;
      &lt;asp:Button ID="Button1" runat="server" BackColor="#6699FF" 
          style="z-index: 1; left: 410px; top: 391px; position: absolute" 
          Text="SAVE" onclick="Button1_Click" /&gt;
  
  &lt;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 HeaderText="Product"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="Label3" runat="server" Text='&lt;%# Bind("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;
  </code></pre>