We have a problem with the SharePoint search field. Whenever we try to find something, we get:
Failed to verify data. in System.Web.Configuration.MachineKeySection.EncryptOrDecryptData (Boolean fEncrypt, Byte [] buf, Byte [] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo) in System.WebStateateIformatebimeterm .
Does anyone know the reason for this exception or the way around it?
New entry:
I use SPGridView, where I use the datakeys property in the web part. The web page is working, but we found that using the datakeys property breaks in that if you try to use the search text box and click on the seach button, it will get this exception:
Failed to verify data. in System.Web.Configuration.MachineKeySection.EncryptOrDecryptData (Boolean fEncrypt, Byte [] buf, Byte [] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo) in System.WebState.FormateObject.Data
This is what I tried to do:
Make gridview not spgridview and set autogenerate true (works) Delete datakeynames (works) Test with empty grid (failures) Test with non-empty gridview (failures) Change machine keys (failures) Rotate view state on the grid (failures) Move gridview ti to ascx file (failure)
I can't seem to figure this out. Did enyone really get this error and get around it?
EDit 09/10/2009
. MSDN . MSDN
public class TestErrorGridView : System.Web.UI.WebControls.WebParts.WebPart
{
Control ascxToAdd;
protected DataTable PropertyCollection = new DataTable();
private DataColumn key;
public TestErrorGridView()
{
key = PropertyCollection.Columns.Add("ID", typeof(string));
PropertyCollection.Columns.Add("Name", typeof(string));
}
public void AddProperty(TestBindObject data)
{
DataRow newRow = PropertyCollection.Rows.Add();
newRow["ID "] = data.ID;
newRow["Name"] = data.Name;
}
public void BindGrid(SPGridView grid)
{
SPBoundField fldPropertyName = new SPBoundField();
fldPropertyName.HeaderText = "ID";
fldPropertyName.DataField = "ID";
grid.Columns.Add(fldPropertyName);
SPBoundField fldPropertyValue = new SPBoundField();
fldPropertyValue.HeaderText = "Name";
fldPropertyValue.DataField = "Name";
grid.Columns.Add(fldPropertyValue);
PropertyCollection.PrimaryKey = new DataColumn[] { key };
grid.DataSource = PropertyCollection.DefaultView;
grid.DataKeyNames = new string[] { key.ColumnName };
grid.DataBind();
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}
protected override void CreateChildControls()
{
base.CreateChildControls();
TestBindObject t1 = new TestBindObject() { ID = 1, Name = "Test3" };
this.AddProperty(t1);
SPGridView testGrid = new SPGridView() { AutoGenerateColumns = false };
this.BindGrid(testGrid);
this.Controls.Add(testGrid);
}
}
[Serializable]
public class TestBindObject
{
public int ID { get; set; }
public string Name { get; set; }
}