0

我正在使用DevExpress GridView. 我只需要在最后一页显示总数。所以,我需要检查是否grid.PageIndex == grid.PageCount. 但是PageIndex设置为不相关的随机数(至少我没有找到任何逻辑),而且我不知道我的代码中缺少什么。

 <dx:ASPxGridView ID="GrdMain" ClientInstanceName="GrdMain" runat="server" 
        KeyFieldName="SomeId" Width="100%" AutoGenerateColumns="False">
 <Columns>
    <dx:GridViewDataTextColumn FieldName="Debit" VisibleIndex="6" UnboundType="Decimal">
    </dx:GridViewDataTextColumn>
</Columns>

<Settings ShowFooter="True" />
<TotalSummary>
    <dx:ASPxSummaryItem FieldName="Debit" SummaryType="Sum"/>
</TotalSummary>

和后面的代码:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            grid.SettingsPager.PageSize = 25;
            grid.ForceDataRowType(typeof(SomeTypeView));
        }
        SetGridDataSource();
    }

    private void SetGridDataSource()
    {
        grid.DataSource = GetListOfSomeType();
        grid.DataBind();
        grid.Settings.ShowFooter = (grid.PageIndex == grid.PageCount - 1);
    }
4

1 回答 1

0

这就是我解决问题的方法,但仍然不知道为什么grid.PageIndex在上面的代码中包含随机值。

    private void SetGridDataSource()
    {                        
        grid.DataSource = GetListOfSomeType();
        grid.DataBind();

        grid.PageIndexChanged += new EventHandler(grid_PageIndexChanged);
    }

    void grid_PageIndexChanged(object sender, EventArgs e)
    {
        grid.Settings.ShowFooter = (grid.PageIndex == grid.PageCount - 1);
    }
于 2013-08-20T04:06:31.023 回答