title: add columns with textboxes in gridview using C#
body: <p>I'm working on a shopping cart in a website and I have my items(which have been added to the cart) in an arraylist. And using these values I've read the rest of the values from the db and and have populated on the gridview successfully.</p>
  
  <pre><code>        if (d1.Read())
          {
              d1.Close();
              sda.SelectCommand = searchResult;
              sda.Fill(dt);
              GridView2.DataSource = dt;
              GridView2.DataBind();
          }
  </code></pre>
  
  <p>How can I add an additional column named "Quantity" in this gridview along with a text box so that user can enter a value for the qunatity for each item displayed in the gridview?</p>
  
  <p>Any help/suggestions/links would be greatly appreciated.</p>
  
  <p>thanks,</p>
  
  <p>//edit 2</p>
  
  <pre><code>&lt;asp:GridView ID="GridView2" runat="server" BackColor="#388AD0"
      BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black"
      GridLines="Vertical" Height="160px" Style="left: 72px;
      position: relative; top: 8px" Width="504px" AllowPaging="True" PageSize="5"&gt;
      &lt;FooterStyle BackColor="#E0E0E0" /&gt;
      &lt;PagerStyle BackColor="Silver" ForeColor="Black" HorizontalAlign="Center" /&gt;
      &lt;SelectedRowStyle BackColor="#388AD0" Font-Bold="True" ForeColor="White" /&gt;
      &lt;HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" /&gt;
      &lt;AlternatingRowStyle BackColor="#388AD0" /&gt;
      &lt;PagerSettings Mode="NextPrevious" /&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>//edit 3</p>
  
  <pre><code>public void additem(string additem) 
  {
      DataTable dt = new DataTable();
      string ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ewap_k.mdf;Integrated Security=True;User Instance=True";
      using (SqlConnection searchCon = new SqlConnection(ConnectionString))
      {
          using (SqlCommand searchResult = new SqlCommand("SELECT ItemID, Name, RelDate, Price, Status FROM item_k WHERE ItemID IN ( " + itemIDs + ")", searchCon))
          {
              searchCon.Open();
              SqlDataReader d1 = searchResult.ExecuteReader();
              SqlDataAdapter sda = new SqlDataAdapter();
  
              if (d1.Read())
              {
                  d1.Close();
                  sda.SelectCommand = searchResult;
                  sda.Fill(dt);
                  GridView1.DataSource = dt;
                  GridView1.DataBind();
              }
              else { }
              searchCon.Close();
          }
      }
  }
  </code></pre>
  
  <p>//edit 4</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server" Style="left: 8px; position: relative;
      top: 0px"&gt;
      &lt;Columns&gt;
          &lt;asp:BoundField DataField="ItemID"  Visible="false"/&gt;
          &lt;asp:BoundField DataField="Name" /&gt;
          &lt;asp:BoundField DataField="RelDate" /&gt;
          &lt;asp:TemplateField&gt;
          &lt;ItemTemplate&gt;
              &lt;asp:TextBox ID="TextBox1" runat="server" Text=""&gt;&lt;/asp:TextBox&gt;
          &lt;/ItemTemplate&gt;
      &lt;/asp:TemplateField&gt;
          &lt;asp:BoundField DataField="Price" /&gt;
          &lt;asp:BoundField DataField="Status" /&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>