Can't get new value from a text box in side a gridview
<p>Hello I'm doing a school project and I'm stuck on a problem any help would be great</p>

<p>i have a Shopping Cart Gridview that has a text box quantity where a user can change quantity value for some reason it is not getting the new value just the old value thank you!</p>

<pre><code>&lt;div class="container"&gt;
            &lt;h1&gt;Shopping Cart&lt;/h1&gt;
            &lt;a href="Default.aspx"&gt;&amp;lt; Back to Products&lt;/a&gt;
            &lt;br /&gt;&lt;br /&gt;
        &lt;asp:Label ID="Label2" runat="server" &gt;&lt;/asp:Label&gt;
        &lt;asp:Label ID="Label3" runat="server" &gt;&lt;/asp:Label&gt;
            &lt;asp:GridView runat="server" ID="gvShoppingCart" AutoGenerateColumns="false" EmptyDataText="There is nothing in your shopping cart." GridLines="None" Width="100%" CellPadding="5" ShowFooter="true" DataKeyNames="ProductID" OnRowDataBound="gvShoppingCart_RowDataBound" OnRowDeleting="grdCart_RowDeleting" &gt;
                &lt;HeaderStyle HorizontalAlign="Left" BackColor="#3D7169" ForeColor="#FFFFFF" /&gt;
                &lt;FooterStyle HorizontalAlign="Right" BackColor="#6C6B66" ForeColor="#FFFFFF" /&gt;
                &lt;AlternatingRowStyle BackColor="#F8F8F8" /&gt;
                &lt;Columns&gt;
                    &lt;asp:BoundField DataField="ProductName" HeaderText="Brand" /&gt;
                    &lt;asp:TemplateField HeaderText="Quantity"&gt;
                        &lt;ItemTemplate&gt;
                            &lt;asp:TextBox runat="server" ID="txtQuantity" Columns="5" Text='&lt;%# Eval("Quantity") %&gt;'&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;                            
                        &lt;/ItemTemplate&gt;
                    &lt;/asp:TemplateField&gt;
                    &lt;asp:BoundField DataField="Price" HeaderText="Price" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" DataFormatString="{0:C}"  /&gt;
                    &lt;asp:BoundField DataField="SubTotal" HeaderText="Total" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" DataFormatString="{0:C}" /&gt;
                    &lt;asp:CommandField ShowDeleteButton="True" /&gt;
                &lt;/Columns&gt;
            &lt;/asp:GridView&gt;
            &lt;br /&gt;
            &lt;asp:Button runat="server" ID="btnUpdateCart" Text="Update Cart" OnClick="btnUpdateCart_Click" /&gt;&lt;br /&gt;
            &lt;asp:Button ID="btnClose2" runat="server" Text="Close" Width="50px" /&gt;
        &lt;/div&gt;
</code></pre>

<p>The code behind</p>

<pre><code>protected void btnUpdateCart_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow row in gvShoppingCart.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                // We'll use a try catch block in case something other than a number is typed in
                // If so, we'll just ignore it.
                try
                {
                    // Get the productId from the GridView's datakeys
                    int productId = Convert.ToInt32(gvShoppingCart.DataKeys[row.RowIndex].Value);
                    Label2.Text = productId.ToString();
                    // Find the quantity TextBox and retrieve the value
                    int quantity = int.Parse(((TextBox)row.Cells[1].FindControl("txtQuantity")).Text);

                    Label3.Text = quantity.ToString();
                    ShoppingCart.Cart.Instance.SetItemQuantity(productId, quantity);
                    BindData();
                }
                catch (FormatException) { }
            }
        }

        mpe2.Show();
    }
</code></pre>
