GridView RowUpdating not retrieving newvalues (only oldvalues)

Discussion in 'ASP .Net' started by s.bussing@symax.nl, Dec 12, 2006.

  1. Guest

    Hi, I have been struggling with the GridView the whole day, but can not
    get this solved.

    The rowupdating event in my Gridview doesn't give me the new values
    only the old ones.
    In my GridView I do not use a DataSourceObject and can therefore not
    use e.NewValues or e.OldValues
    The columns used are template columns


    Thx

    Below some codesnippets I use:

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    BindData();
    }
    else
    {
    if (ViewState["BestellingAfdeling"] != null)
    _BeBestellingAfdeling =
    (BEBestellingAfdeling)ViewState["BestellingAfdeling"];
    }
    }


    protected void grvCategorie_UpdatingCommand(object sender,
    GridViewUpdateEventArgs e)
    {
    int _CategorieId =
    Convert.ToInt32(grvCategorie.DataKeys[e.RowIndex]["fldCategorieId"]);
    BEBestellingAfdeling.tblCategorieRow _drCategorieRow =
    _BeBestellingAfdeling.tblCategorie.FindByfldCategorieID(_CategorieId);

    if (_drCategorieRow != null)
    {
    _drCategorieRow.BeginEdit();
    _drCategorieRow.fldOmschrijving =
    ((TextBox)grvCategorie.Rows[e.RowIndex].FindControl("tbxOmschrijving")).Text;
    _drCategorieRow.fldStatus =
    ((CheckBox)grvCategorie.Rows[e.RowIndex].FindControl("cbxStatus")).Checked;
    _drCategorieRow.EndEdit();
    }

    grvCategorie.EditIndex = -1;
    ReBindDataToControl();
    }
     
    , Dec 12, 2006
    #1
    1. Advertising

  2. Guest

    Nevermind, see below for the problem.

    In my GV I use ImageButton to handel edit, cancel and update logic. In
    my codebehind file I have a procudure checking for the e.command
    argument in the GridView_RowCommand. The problem was that in this
    particular procedure I did a ReBind from the GV, which means, I lost
    all my changes and could only see the old (original) values.

    The next link helped me a lot:

    http://groups.google.nl/group/microsoft.public.dotnet.framework.aspnet/browse_frm/thread/
    684ca465e9bcdbac/b712f23981099d17?lnk=st&q=Gridview+editing+without+ObjectDataSource&rnum=7#b712f23981099d17

    In summary: due to rebinding on the wrong moment I lost my changes.
     
    , Dec 13, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Olbert

    GridView: Empty OldValues, NewValues

    Mark Olbert, Jan 19, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    12,478
    jfortier2
    Jul 22, 2006
  2. loga123
    Replies:
    0
    Views:
    1,493
    loga123
    Jun 23, 2006
  3. xs8899
    Replies:
    0
    Views:
    822
    xs8899
    May 22, 2009
  4. Ryan
    Replies:
    1
    Views:
    180
  5. Pulkit Sharma

    Gridview e.OldValues and e.NewValues are nothing

    Pulkit Sharma, Jul 24, 2007, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    1,429
    Rachna
    Nov 19, 2007
Loading...

Share This Page