Dnn PagingControl
How to use it?
*.ascx文件:
<dnn:PagingControl Visible="false" id="pcgv" runat="server"></dnn:PagingControl>
CodeFile:
Code
if (PageSize == 0 || _TotalRecs <= PageSize)
{
pcgv.Visible = false;
}
else
{
pcgv.Visible = true;
pcgv.TotalRecords = _TotalRecs;
pcgv.PageSize = PageSize;
pcgv.CurrentPage = CurrentPage;
pcgv.TabID = TabId;
pcgv.QuerystringParams = PagerQstr();
}
要想使用上面的代码,还需要PagedDataSource的支持。如下:
Code
PagedDataSource objPagedDataSource = new PagedDataSource();
objPagedDataSource.DataSource = gvOldSource();
if (PageSize > 0)
{
objPagedDataSource.PageSize = PageSize;
objPagedDataSource.CurrentPageIndex = CurrentPage - 1;
objPagedDataSource.AllowPaging = true;
}
//Bind the datalist
gv.DataSource = objPagedDataSource;
gv.DataBind();
btw: gv是一个GridView控件。