Home > Blogroll, development, error, Microsoft SharePoint 2010, MOSS, MS SharePoint Sever, sps > Viewstate error on sharepoint custom page

Viewstate error on sharepoint custom page

Created a custom aspx form in my sharepoint application. Put that under layouts folder. Placed a gridview control on it and started receiving the following 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 must match the type and position of the controls added during the initial request.   at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)    at System.Web.UI.Control.AddedControl(Control control, Int32 index)    at xxxxx.SharePoint.EventsMgmt.BookingForm.RenderSearchResults(DataTable roomAvailabilityTable)    at Telstra.SharePoint.EventsMgmt.BookingForm.OnClickOK(Object Sender, EventArgs e)    at System.Web.UI.WebControls.Button.OnClick(EventArgs e)    at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)    at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Solution:

Set enableViewState=false in gridview tag on the aspx page…….(not code behind). solved the problem.

Hope this helps-

Rehman.

Advertisements
  1. April 6, 2011 at 12:55 pm

    Helped me, thanks for sharing!

  2. anon
    May 28, 2013 at 5:19 pm

    worked with radgrid from telerik.
    Thanks

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: