Devexpress grid - PerformCallback generates Invalid viewstate
I have a DevExpress grid that needs to be refreshed every time the value in a combobox is changed. For example, I have a combobox that sets the grid's page size. One of the requirements is that the combobox does not cause a full postback.
The combobox is declared like this:
<asp:DropDownList ID="cboPages" AutoPostBack="false" runat="server"
EnableViewState="false" OnSelectedIndexChanged="cboPages_SelectedIndexChanged" />
On selected index changed, it sets a cookie whose value is the selected value. When the combobox value changes, a javascript function is called:
function PerformCallbackOnGrid(grid) {
try {
grid.PerformCallback("refresh");
}
catch(err){
alert('Could not perform callback on grid.');
}
}
The function is attached in code behind:
this.cboPages.Attributes["onChange"] = "PerformCallbackOnGrid(" + this.GridClientID + ")";
After performing these steps开发者_如何学Go:
- The user changes the grid page size using the combobox, so PerformCallback is called at least once.
- The user presses F5(refresh).
- The user tries to change the page size again.
an 'Invalid viewstate' error message appears.
I have tried setting ViewStateMode to Disabled for the grid, also EnableViewState="false".
Figgured it out by myself! Apparently it was enough to set
EnableViewState="false" EnableRowsCache="false"
to the grid.
Rows cache was the one causing the viewstate error.
精彩评论