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() %> <a title="第一頁" href="JavaScript:dxgvGrid.GotoPage(0);"> <<</a> <a title="上一頁" href="JavaScript:dxgvGrid.PrevPage();"><</a> 頁 <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%> <a title="下一頁" href="JavaScript:dxgvGrid.NextPage();">></a> <a title="最後一頁" href="JavaScript:dxgvGrid.GotoPage(<%# dxgvGrid.PageCount - 1 %>);"> >></a> </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