views:

949

answers:

3

I've got a custom site page in Windows SharePoint Services 3.0 that contains an SPGridView. When I use the search box on this page, I get the following error:

Unable to validate data.   at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo) 
   at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)

Removing the SPGridView from the page fixes this problem, but otherwise I'm not sure how to go about troubleshooting the problem.

This is on a fresh, default install of WSS3, so I don't think it has to do with any other customizations (master pages, etc.). I have one other custom site page in this feature (which doesn't include an SPGridView), but I can use the search box on that page without causing an error.

A: 

Is the application running in a webfarm environment?
If so the machineKey must be set in web.config:
We use the machineKey generator from eggheadcafe
More about Viewstate and webfarms here

Kb
No, this is happening in my development environment, which is a Virtual PC. It's also happening on the dev server we've deployed it to.
DylanW
A: 

Hi, The searchbox in SharePoint seems to use the hidden fields at the bottom of the masterpage.
< input type="text" name="__spDummyText1" style="display:none;" size=1/>
< input type="text" name="__spDummyText2" style="display:none;" size=1/> So if you've done anything with these fields in the application.master or to the Utility Content Placeholder, it won't work.
On the other hand, we have been using SPGridView in our pages without any problems.

SharePoint Newbie
+1  A: 

OK, I finally figured out what the problem was (in my particular case, anyway): I was specifying the DataKeyNames attribute of the SPGridView. After removing that attribute, search worked just fine.

DylanW