Gridview1.Enableviewstate = false

Last post 04-03-2009 2:19 AM by vinz. 1 replies.

Sort Posts:

  • Gridview1.Enableviewstate = false

    04-02-2009, 11:34 PM
    • Member
      1 point Member
    • dallasnative
    • Member since 04-03-2009, 3:18 AM
    • Posts 6

    I am creating a Gridview and binding it to a collection on the selectedindexchange event of a dropdown.

    <asp:GridView ID="grv" runat="server" AutoGenerateColumns = "false" DataKeyNames = "DRID" OnRowDataBound="grv_RowDataBound"

    OnRowEditing = "grv_RowEditing" OnRowCancelingEdit = "grv_RowCancelingEdit" OnRowUpdating = "grv_RowUpdating"

    OnRowDeleting = "grv_RowDeleting" EnableViewState="false" OnRowUpdated = "grv_RowUpdated">

    I have templatecolumns and commandfield inside this gridview.

    With a click of a button outside gridview I am adding a new row and adding it to my collection and gridvew.

    Now, when i am trying to edit the rows , OnRowUpdating is not getting fired. Previously, I had viewstate on but it was throwing me error :

    Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back

    The row_updating event was also getting fired with this setting (EnableViewstate = true). How can I make my dynamic row work with the updation.

    Appreciate your responses!!!! 

     

  • Re: Gridview1.Enableviewstate = false

    04-03-2009, 2:19 AM
    Answer
    • All-Star
      90,673 point All-Star
    • vinz
    • Member since 10-05-2007, 3:47 PM
    • Cebu, Philippines
    • Posts 13,649
    • TrustedFriends-MVPs

    dallasnative:
    Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back
     

    try to check this thread for a solution: http://forums.asp.net/t/1295517.aspx

     


    Best Regards,
    Vincent Maverick Durano
    SDE|Microsoft MVP - ASP/ASP.NET

    "Code,Beer and Music ~ my way of being a programmer"
Page 1 of 1 (2 items)