Question

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:

  1. The user changes the grid page size using the combobox, so PerformCallback is called at least once.
  2. The user presses F5(refresh).
  3. 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".

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top