[SOLVED] ASPxPivotGrid Loss data on post back

Issue

I attach a data source to ASPxPivotGrid on page load it shows the data, it loses data when the filter, sort, or paging button is pressed.

private void LoadBankDetail1(string branch, DateTime dateFrom, DateTime dateTo, string accounts)
 {

            ASPxPivotGrid1.DataSource = aglTransact.GetBankDetail(branch, dateFrom, dateTo, accounts, inputIncludOb.Checked);
}


<dx:ASPxPivotGrid ID="ASPxPivotGrid1" runat="server" ClientIDMode="AutoID"  EnableTheming="True" OnDataBinding="ASPxPivotGrid1_DataBinding" Theme="MaterialCompact">
    <Fields>
        <dx:PivotGridField ID="fieldaccountdesc" Area="RowArea" AreaIndex="1" Caption="Account" FieldName="account_desc" Name="fieldaccountdesc">
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldperiod" Area="ColumnArea" AreaIndex="0" Caption="Period" FieldName="period" Name="fieldperiod">
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldamount" Area="DataArea" AreaIndex="0" Caption="Amount" FieldName="amount" Name="fieldamount">
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldbranchdesc" Area="RowArea" AreaIndex="0" Caption="Branch" FieldName="branch_desc" Name="fieldbranchdesc">
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldbranchdesc1" AreaIndex="0" Caption="Branch" FieldName="branch_desc" Name="fieldbranchdesc1">
        </dx:PivotGridField>
    </Fields>
</dx:ASPxPivotGrid>

Solution

Make sure that you call the "LoadBankDetail1" procedure (where you assign ASPxPivotGrid1.DataSource) during EACH request, i.e., NOT under something like "if (!IsPostBack)" etc. on Page_Load:

protected void Page_Load(object sender, EventArgs e) {
    LoadBankDetail1(...);
}

Answered By – Mikhail

Answer Checked By – Marie Seifert (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *