博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
<dxwgv:ASPxGridView
阅读量:6817 次
发布时间:2019-06-26

本文共 2318 字,大约阅读时间需要 7 分钟。

HtmL

<dxwgv:ASPxGridView ID="dxgvGrid" runat="server" ClientInstanceName="dxgvGrid" AutoGenerateColumns="False" KeyFieldName="PERSON_ID" oncustomcallback="dxgvGrid_CustomCallback" >

<Settings ShowStatusBar="Visible" />

                            <SettingsPager Visible="false">
                            </SettingsPager>
                            <Templates>
                                <StatusBar>
                                    <div style="text-align: right;">
                                        每頁記錄數:
                                        <select οnchange="dxgvGrid.PerformCallback(this.value);">
                                            <option value="5" <%# WriteSelectedIndex(5) %>>5</option>
                                            <option value="10" <%# WriteSelectedIndex(10) %>>10</option>
                                            <option value="20" <%# WriteSelectedIndex(15) %>>20</option>
                                            <option value="50" <%# WriteSelectedIndex(20) %>>50</option>
                                            <option value="100" <%# WriteSelectedIndex(25) %>>100</option>
                                        </select>
                                        <%#GetShowingOnPage() %>&nbsp; <a title="第一頁" href="JavaScript:dxgvGrid.GotoPage(0);">
                                            &lt;&lt;</a> &nbsp; <a title="上一頁" href="JavaScript:dxgvGrid.PrevPage();">&lt;</a>
                                        &nbsp; 頁
                                        <input type="text" οnchange="dxgvGrid.GotoPage(parseInt(this.value, 10) - 1)"
                                            οnkeydοwn="if (event.keyCode == 13) { event.cancelBubble=true; event.returnValue = false; dxgvGrid.GotoPage(parseInt(this.value, 10) - 1); return false; }"
                                            value="<%# dxgvGrid.PageIndex + 1 %>" style="width: 20px" />
                                        of
                                        <%# dxgvGrid.PageCount%>
                                        &nbsp; <a title="下一頁" href="JavaScript:dxgvGrid.NextPage();">&gt;</a> &nbsp;
                                        <a title="最後一頁" href="JavaScript:dxgvGrid.GotoPage(<%# dxgvGrid.PageCount - 1 %>);">
                                            &gt;&gt;</a> &nbsp;
                                    </div>
                                </StatusBar>
                            </Templates>

.cs

#region 分頁操作

    protected void dxgvGrid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
    {
        int newPageSize;
        if (!int.TryParse(e.Parameters, out newPageSize)) return;
        dxgvGrid.SettingsPager.PageSize = newPageSize;
        Session[GridCustomPageSizeName] = newPageSize;
        dxgvGrid.DataBind();
    }

    protected string WriteSelectedIndex(int pageSize)

    {
        return pageSize == dxgvGrid.SettingsPager.PageSize ? "selected='selected'" : string.Empty;
    }
    protected string GetShowingOnPage()
    {
        int pageSize = dxgvGrid.SettingsPager.PageSize;
        int startIndex = dxgvGrid.PageIndex * pageSize + 1;
        int endIndex = (dxgvGrid.PageIndex + 1) * pageSize;
        if (endIndex > dxgvGrid.VisibleRowCount)
        {
            endIndex = dxgvGrid.VisibleRowCount;
        }
        return string.Format("當前記錄 {0}-{1} of {2}", startIndex, endIndex, dxgvGrid.VisibleRowCount);
    }
    #endregion

转载于:https://www.cnblogs.com/rongnianwu/archive/2012/12/10/2810978.html

你可能感兴趣的文章
以太坊(ethereum)技术开发相关资料
查看>>
Pandas数据排序
查看>>
gulp常用插件
查看>>
2018 前端趋势:更一致,更简单
查看>>
SQL物化视图 自动更新 定时刷新
查看>>
express框架应用接入阿里云函数计算
查看>>
几行代码实现ofo首页小黄人眼睛加速感应转动
查看>>
317TABLE ACCESS BY INDEX ROWID BATCHED3
查看>>
MapReduce Shuffle原理 与 Spark Shuffle原理
查看>>
题解 P3386 【【模板】二分图匹配】
查看>>
李彦宏:人工智能的互联网时代已经到来
查看>>
游标概念和作用(转载)
查看>>
python中全局变量、局部变量、类变量、实例变量简析
查看>>
大众公布量子计算北京交通新一代产品亮相
查看>>
武器加持无人机,远程操控就可以抓获犯罪团伙
查看>>
MySQL数据库迁移
查看>>
IOS应用提交所需的ICON
查看>>
第90届中国电子展聚焦行业新热点,拉动产业链上下游快速发展
查看>>
量子力学多世界解释:这个世界的你是穷光蛋 另一个世界是亿万富翁(文中有赠书活动)...
查看>>
不要小看了互联网智能锁,它正撬动整个多元化居住产品时代!
查看>>