使用SPGridView在SharePoint自定义网站页面上显示Viewstate错误

时间:2009-01-01 16:02:27

标签: sharepoint spgridview

我在Windows SharePoint Services 3.0中有一个包含SPGridView的自定义网站页面。当我使用此页面上的搜索框时,出现以下错误:

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)  

从页面中删除SPGridView可以解决此问题,但除此之外我不确定如何解决问题。

这是在WSS3的全新默认安装上,所以我认为它不与任何其他自定义(母版页等)有关。我在此功能中有另一个自定义网站页面(不包含SPGridView),但我可以使用该页面上的搜索框而不会导致错误。

3 个答案:

答案 0 :(得分:1)

好的,我终于弄明白了问题是什么(在我的特定情况下,无论如何):我正在指定SPGridView的DataKeyNames属性。删除该属性后,搜索工作正常。

答案 1 :(得分:0)

应用程序是否在webfarm环境中运行? 如果是这样,必须在web.config中设置machineKey:
我们使用eggheadcafe的machineKey生成器 有关Viewstate和webfarms的更多信息here

答案 2 :(得分:0)

SharePoint中的搜索框似乎使用了母版页底部的隐藏字段      < input type =“text”name =“__ spDummyText1”style =“display:none;”大小= 1 />
     < input type =“text”name =“__ spDummyText2”style =“display:none;”大小= 1 /> 因此,如果您在application.master或Utility Content Placeholder中对这些字段执行了任何操作,则无法使用 另一方面,我们在页面中使用SPGridView没有任何问题。

相关问题