title: Get value of databound cell in GridView
body: <p>I have been trying this out for a while now and can't seem to figure it out. I can extract the controls in the gridview fine, but I need to get the values of the databound cells in the GridView, and cant seem to find out how. Here is my code:</p>
  
  <p>Webpage:</p>
  
  <pre><code> &lt;asp:GridView ID="ReceiverPanel" runat="server" AutoGenerateColumns="False" DataSourceID="ODSPopulatePOItemList"&gt;
      &lt;Columns&gt;
          &lt;asp:BoundField DataField="PurchaseOrderID" HeaderText="PurchaseOrderID" SortExpression="PurchaseOrderID" Visible="False" /&gt;
          &lt;asp:BoundField DataField="StockItemID" HeaderText="StockItemID" SortExpression="StockItemID" /&gt;
          &lt;asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" /&gt;
          &lt;asp:BoundField DataField="QuantityOnOrder" HeaderText="QuantityOnOrder" SortExpression="QuantityOnOrder" /&gt;
          &lt;asp:BoundField DataField="QuantityOutstanding" HeaderText="Outstanding" SortExpression="QuantityOutstanding" /&gt;
          &lt;asp:TemplateField HeaderText="Receive"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:TextBox runat="server" ID="Received" Text='&lt;%# Eval("Received") %&gt;'&gt;&lt;/asp:TextBox&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Return"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:TextBox runat="server" ID="Returned" Text='&lt;%# Eval("ReturnedQuantity") %&gt;'&gt;&lt;/asp:TextBox&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Reason"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:TextBox runat="server" ID="Reason" Text='&lt;%# Eval("Reason") %&gt;'&gt;&lt;/asp:TextBox&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Code Behind:</p>
  
  <pre><code>protected void ReceiveButton_Click(object sender, EventArgs e)
  {
  
      // Gather data from gridview
      foreach (GridViewRow row in ReceiverPanel.Rows)
      {
          // Find controls in the Gridview
          //var purchaseOrderIdCtrl = row.FindControl("PurchaseOrderID") as HiddenField;
          //var stockItemCtrl = row.FindControl("")
          var receivedCtrl = row.FindControl("Received") as TextBox;
          var returnedCtrl = row.FindControl("Returned") as TextBox;
          var reasonCtrl = row.FindControl("Reason") as TextBox;
          //SELECT DATABOUND CONTROL var stockItemNo = row.SelectedRow.Cells[2].Text ;
  
          //int stockItemNum = int.Parse(stockItemNo);
          int received = int.Parse(receivedCtrl.Text);
          int returned = int.Parse(returnedCtrl.Text);
          string reason = reasonCtrl.Text;
  
          Update_StockItem(stockItemNum, received);
      }
  </code></pre>
  
  <p>Is there a simple way to grab the values from the GridView? Any help would be greatly appreciated.</p>