C#怎么把数据查出来了再进行分页啊
C#怎么把数据查出来了再进行分页啊
------解决方案--------------------
/// <summary>
/// 分页
/// </summary>
protected void page()
{
BLL.Blog_Log bll = new BLL.Blog_Log();
DataTable dt = bll.GetLogandType().Tables[0];
//创建一个分页的类
PagedDataSource page = new PagedDataSource();
//为分页类设定数据源
page.DataSource = dt.DefaultView;
//设置为允许分页
page.AllowPaging = true;
//每页显示的数据项
page.PageSize = 10;
//显示共几页
LblTotalPage.Text = "共" + page.PageCount.ToString() + "页";
//用一个变量来记录当前页数
int currentpage;
//判断是否有请求页面
if (Request.QueryString["id"] != null)
{
currentpage = Convert.ToInt32(Request.QueryString["id"]);
}
else
{
currentpage = 1;
}
page.CurrentPageIndex = currentpage - 1;
LblCurent.Text = "当前第" + currentpage + "页";
//上一页
if (!page.IsFirstPage)
{
HyperLinkUp.NavigateUrl = Request.CurrentExecutionFilePath + "?id=" + Convert.ToString(currentpage - 1);
}
//下一页
if (!page.IsLastPage)
{
HyperLinkDown.NavigateUrl = Request.CurrentExecutionFilePath + "?id=" + Convert.ToString(currentpage + 1);
}
DataList_Log.DataSource = page;
DataList_Log.DataBind();
}
------解决方案--------------------
http://hi.baidu.com/hjywyj/ihome/myblog