?? default.aspx.cs
字號:
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;
public partial class ReverseUrlPageIndex_Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//cache the number of total records to improve performance
object obj = Cache[GetType()+"totalOrders"];
if (obj == null)
{
int totalOrders = (int) SqlHelper.ExecuteScalar(CommandType.StoredProcedure, "P_GetOrderNumber");
Cache[GetType()+"totalOrders"] = totalOrders;
AspNetPager1.RecordCount = totalOrders;
}
else
{
AspNetPager1.RecordCount = (int) obj;
}
}
}
protected void AspNetPager1_PageChanged(object src, EventArgs e)
{
int startIndex = AspNetPager1.StartRecordIndex;
//如果是最后一頁,則重新設置起始記錄索引,以使最后一頁的記錄數與其它頁相同,如總記錄有101條,每頁顯示10條,如果不使用此方法,則第十一頁即最后一頁只有一條記錄,使用此方法可使最后一頁同樣有十條記錄。
if (AspNetPager1.CurrentPageIndex == AspNetPager1.PageCount)
startIndex = AspNetPager1.RecordCount - AspNetPager1.PageSize+1;
GridView1.DataSource = SqlHelper.ExecuteReader(CommandType.StoredProcedure, ConfigurationManager.AppSettings["pagedSPName"],
new SqlParameter("@startIndex", startIndex),
new SqlParameter("@endIndex", AspNetPager1.EndRecordIndex));
GridView1.DataBind();
AspNetPager1.CustomInfoHTML = "Page <font color=\"red\"><b>" + AspNetPager1.CurrentPageIndex + "</b></font> of " + AspNetPager1.PageCount;
AspNetPager1.CustomInfoHTML += " Orders " + AspNetPager1.StartRecordIndex + "-" + AspNetPager1.EndRecordIndex;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -