我們有一個使用搜索的Sharepoint站點。使用DataKeyname時Sharepoint搜索失敗
我們得到以下錯誤:
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)
位測試,我們發現後,當我們使用DateKeyNames在GridView控件發生錯誤。
不知道爲什麼應該有搜索,這個錯誤和DataKeyNames之間的任何組合。
任何想法?
更新:下面是一些代碼
[Guid("8891224e-e830-4ffa-afbd-f789583d8d14")]
public class TestErrorGridView : System.Web.UI.WebControls.WebParts.WebPart
{
Control ascxToAdd;
public TestErrorGridView()
{
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}
protected override void CreateChildControls()
{
base.CreateChildControls();
Table test = new Table();
TestBindObject t1 = new TestBindObject() { ID = 1, Name = "Test" };
List<TestBindObject> l1 = new List<TestBindObject>();
l1.Add(t1);
SPGridView testGrid = new SPGridView() { AutoGenerateColumns = false};
BoundField header = new BoundField();
header.DataField = "ID";
BoundField name = new BoundField();
name.DataField = "Name";
testGrid.Columns.Add(header);
testGrid.Columns.Add(name);
testGrid.DataSource = l1;
testGrid.DataBind();
// If you comment out this line search works
testGrid.DataKeyNames = new string[] { "ID" };
this.Controls.Add(testGrid);
base.CreateChildControls();
SPGridView testGrid = new SPGridView() { AutoGenerateColumns = false, EnableViewState=false };
testGrid.DataKeyNames = new string[] { "testid" };
this.Controls.Add(testGrid);
}
}
public class TestBindObject
{
public int ID { get; set; }
public string Name { get; set; }
}
UPDATE
對開發商的機器這個出現錯誤;所以它不realated機器鍵是在集羣中不同的機器不同。
其中一位開發人員安裝了MOSS,他沒有得到該錯誤。剛剛安裝WSS的開發人員會收到錯誤消息。
更新2
有數據源添加到代碼
你可以發佈錯誤發生的代碼嗎? – 2009-09-18 13:35:43
@Kit添加了一個代碼示例 – 2009-09-18 14:15:41