复制代码 代码如下:
<asp:GridView runat="server">
</asp:GridView>
<webdiyer:AspNetPager runat="server" PageSize="20"
onpagechanging="AspNetPager1_PageChanging">
</webdiyer:AspNetPager>
复制代码 代码如下:
protectedvoid Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
DisplayData(1, AspNetPager1.PageSize);
}
privatevoid DisplayData(int pageIndex, int pageSize)
{
SQLiteData md = new SQLiteData();
AspNetPager1.RecordCount = (int)(Int64)md.ExecuteScalar("select count(*) from city");
DataTable dt = md.FillDataTable(string.Format("select * from city limit {0},{1}", (pageIndex - 1) * pageSize, pageSize));
md.Close();
GridView1.DataSource = dt;
GridView1.DataBind();
}
protectedvoid AspNetPager1_PageChanging(object src, PageChangingEventArgs e)
{
DisplayData(e.NewPageIndex, AspNetPager1.PageSize);
}
AspNetPager控件功能比较强大,这里只不过介绍了最基本用法,以后有机会会介绍其他功能。
新闻热点
疑难解答
图片精选