Updating with using custom class collection not working
<p>I've posted this yesterday on asp forum but no one replied so perhaps I'll have better luck here. For some reason the OnUpdating method does not pull new values from the grid which is in edit mode. I've search and have come across several blogs and sites, some sugesting that an ObjectDataSource is required in order to use the "e.NewValue" construct others provide code to the contrary. I don't get any errors - the variables in the code file would contain the old values rather then new ones. I don't want to use the ODS way of manipulating the data. My delete method works but not the update one. Can you suggest what is wrong with the code? Here is what I've got:</p>

<pre><code>&lt;asp:GridView ID="gvBlack" runat="server"AutoGenerateColumns="False" OnRowUpdating="gvBlack_OnUpdating" OnRowEditing="gvBlack_RowEditing"&gt; 
 &lt;Columns&gt; 
      &lt;%--&lt;asp:BoundField DataField="Ident_Black" ReadOnly="True" visible="false" /&gt;--%&gt; 
     &lt;asp:TemplateField ItemStyle-Width="1px"&gt; 
        &lt;EditItemTemplate&gt; 
           &lt;asp:Label ID="lblIdent_Black" runat="server" Text='&lt;%# Bind("Ident_Black") %&gt;' Visible="false" /&gt; 
        &lt;/EditItemTemplate&gt; 
     &lt;/asp:TemplateField&gt;

&lt;asp:TemplateField HeaderText="Model" &gt; 
&lt;ItemTemplate&gt; 
&lt;asp:Label ID="lblModel_Black" runat="server" Text='&lt;%# Bind("Model_Black") %&gt;' width="130px" /&gt; 
&lt;/ItemTemplate&gt; 
&lt;EditItemTemplate&gt; 
&lt;asp:TextBox ID="txtModel_Black" runat="server" Text='&lt;%# Eval("Model_Black") %&gt;' width="100px" /&gt; 
&lt;asp:RequiredFieldValidator ID="rfvModel_Black" runat="server" ControlToValidate="txtModel_Black" SetFocusOnError="true" ErrorMessage="*" ValidationGroup="CurrentMfg" ForeColor="Red" Font-Bold="true" /&gt; 
&lt;/EditItemTemplate&gt; 
&lt;/asp:TemplateField&gt;

&lt;asp:TemplateField HeaderText="Description" &gt; 
&lt;ItemTemplate&gt; 
&lt;asp:Label ID="lblDesc_Black" runat="server" Text='&lt;%# Bind("Desc_Black") %&gt;' width="200px" /&gt; 
&lt;/ItemTemplate&gt; 
&lt;EditItemTemplate&gt; 
&lt;asp:TextBox ID="txtDesc_Black"runat="server"Text='&lt;%# Eval("Desc_Black") %&gt;' width="170px" /&gt; &lt;span&gt;&lt;/span&gt; 
&lt;/EditItemTemplate&gt; 
&lt;/asp:TemplateField&gt;

&lt;asp:TemplateField HeaderText="Qty" &gt; 
&lt;ItemTemplate&gt; 
&lt;asp:Label ID="lblQty_Black" runat="server" Text='&lt;%# Bind("Qty_Black") %&gt;' width="35px" /&gt; 
&lt;/ItemTemplate&gt; 
&lt;EditItemTemplate&gt; 
&lt;asp:TextBox ID="txtQty_Black"runat="server"Text='&lt;%# Eval("Qty_Black") %&gt;' width="35px" /&gt; &lt;asp:RequiredFieldValidator ID="rfvQty_Black" runat="server" ControlToValidate="txtQty_Black" SetFocusOnError="true" ErrorMessage="*" ValidationGroup="CurrentMfg" ForeColor="Red" Font-Bold="true" /&gt; 
&lt;/EditItemTemplate&gt; 
&lt;/asp:TemplateField&gt;

&lt;asp:TemplateField HeaderText="Reorder&lt;br /&gt;Limit"&gt; 
&lt;ItemTemplate&gt; 
&lt;asp:Label ID="lblBlack_Reorder_Limit" runat="server" Text='&lt;%# Bind("Black_Reorder_Limit") %&gt;' width="35px" /&gt;
&lt;/ItemTemplate&gt; 
&lt;EditItemTemplate&gt; 
&lt;asp:TextBox ID="txtBlack_Reorder_Limit" runat="server" Text='&lt;%# Eval("Black_Reorder_Limit") %&gt;' width="35px" /&gt; 
&lt;asp:RequiredFieldValidator ID="rfvBlack_Reorder_Limit" runat="server" ControlToValidate="txtBlack_Reorder_Limit" SetFocusOnError="true" ErrorMessage="*" ValidationGroup="CurrentMfg" ForeColor="Red" Font-Bold="true" /&gt; 
&lt;/EditItemTemplate&gt; 
&lt;/asp:TemplateField&gt;

&lt;asp:TemplateField HeaderText="Notes"&gt; 
&lt;ItemTemplate&gt; 
&lt;asp:Label ID="lblNotes" runat="server" Text='&lt;%# Bind("Notes") %&gt;' width="200px" /&gt; 
&lt;/ItemTemplate&gt; 
&lt;EditItemTemplate&gt; 
&lt;asp:TextBox ID="txtNotes" runat="server" Text='&lt;%# Eval("Notes") %&gt;' width="170px" /&gt; &lt;span&gt;&lt;/span&gt; 
&lt;/EditItemTemplate&gt; 
&lt;/asp:TemplateField&gt; 
&lt;asp:CommandField ShowEditButton="True" ShowDeleteButton="false" ValidationGroup="CurrentToner" /&gt; 
&lt;/Columns&gt; 
&lt;/asp:GridView&gt;
</code></pre>

<p>Code file:</p>

<pre><code>protected void Page_Load(object sender, EventArgs e) {
    LoadData_TonerBlack();
}

private void LoadData_TonerBlack() {
    dalConsumables_TonerBlack drTonerBlack = new dalConsumables_TonerBlack();

    gvBlack.DataSource = drTonerBlack.GetListTonersBlack(); gvBlack.DataBind();
}

protected void gvBlack_OnUpdating(object sender, GridViewUpdateEventArgs e) 
{
    //GridView gvBlack = (GridView)sender; 
    //GridViewRow gvBlackRow = (GridViewRow)gvBlack.Rows[e.RowIndex];

    int _Ident_Black = Convert.ToInt32(gvBlack.DataKeys[e.RowIndex].Values[0].ToString());

    TextBox _txtModel_Black = (TextBox)gvBlack.Rows[e.RowIndex].FindControl("txtModel_Black");
    TextBox _txtDesc_Black = (TextBox)gvBlack.Rows[e.RowIndex].FindControl("txtDesc_Black");
    TextBox _txtQty_Black = (TextBox)gvBlack.Rows[e.RowIndex].FindControl("txtQty_Black");
    TextBox _txtBlack_Reorder_Limit = (TextBox)gvBlack.Rows[e.RowIndex].FindControl("txtBlack_Reorder_Limit");
    TextBox _txtNotes = (TextBox)gvBlack.Rows[e.RowIndex].FindControl("txtNotes");
    string _updatedBy = Request.ServerVariables["AUTH_USER"].ToString();

    dalConsumables_TonerBlack updateTonerBlack = new dalConsumables_TonerBlack();
    updateTonerBlack.UpdateTonerBlack(
        _Ident_Black,
        _txtModel_Black.Text,
        _txtDesc_Black.Text,
        Convert.ToInt32(_txtQty_Black.Text),
        Convert.ToInt32(_txtBlack_Reorder_Limit.Text),
        _txtNotes.Text,
        _updatedBy);

    gvBlack.EditIndex = -1;

    LoadData_TonerBlack();
}

protected void gvBlack_RowEditing(object sender, GridViewEditEventArgs e)
{
    gvBlack.EditIndex = e.NewEditIndex; 
    LoadData_TonerBlack();
}
</code></pre>
