Using viewstate Accepts data changes :<

Discussion in 'ASP .Net' started by Egbert Nierop \(MVP for IIS\), Aug 20, 2003.

  1. Hi,

    I have a typed dataset, that is serialized using viewstate.
    Now when a user adds a new row from a certain grid, the new row is added to
    the typed dataset. The database TRANSACTION however, is done only when the
    user clicks 'save record'

    And indeed, the newly added rows (as well as the form data) are retrieved
    and updated EXCEPT the rows from the grid.
    The seem to be accepted (internally by the ViewState???)

    Code (shortened and conceptualized)

    void grid_onaddrow()
    {
    xsd.Blah.tUserGroupsRow row =
    this.myDs.tUserGroups.newUserGroupsRow();
    row.field = "blah";
    row.field2 = DateTime.now;
    this.myDs.tUserGroups.addNewUserGroupsRow(row)

    /// THIS SEEMS TO ACCEPT CHANGS
    ViewState["mydata"] = this.myDs; //store in ViewState
    }


    void button_Save()
    {
    // fetch screen data...
    mySqlAdapter.sqlUser.Update(this.myDs.Users); // Works
    mySqlAdapter.sqlUserGroups.Update(this.myDs.UserGroups); // NO EFFECT
    // it has NO effect because the added/changed rows seem to be accepted at
    the marked line above!
    }
     
    Egbert Nierop \(MVP for IIS\), Aug 20, 2003
    #1
    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.

Share This Page