应该可以,这个分页插件解析完后,依旧是一个html,不过你在查找这个控件的时候,就麻烦点了,需要用repeater去findControl这个插件
public void DataSourcePage(Repeater RName, DataTable dataTable, int pCount, string httpPage, Label lblpc, Label lblp, DropDownList ddlp, HyperLink hlFirst, HyperLink hlProv, HyperLink hlNext, HyperLink hlLast, string strUrl)
{
//分页
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dataTable.DefaultView;
pds.AllowPaging = true;
pds.PageSize = pCount;
int curpage;
if (httpPage != null)
{
curpage = Convert.ToInt32(httpPage);
}
else
{
curpage = 1;
}
pds.CurrentPageIndex = curpage - 1;
lblpc.Text = pds.PageCount.ToString(); //总共页数
lblp.Text = Convert.ToString(pds.CurrentPageIndex + 1); //当前页数
//绑定跳转页数
for (int i = 0; i < pds.PageCount; i++)
{
ddlp.Items.Add((i + 1).ToString());
}
//跳转链接
if (pds.IsFirstPage && !pds.IsLastPage)
{
hlProv.Enabled = false;
hlNext.NavigateUrl = strUrl + Convert.ToInt32(curpage + 1);
hlFirst.Enabled = false;
hlLast.NavigateUrl = strUrl + Convert.ToInt32(pds.PageCount);
}
else
{
if (pds.IsLastPage && !pds.IsFirstPage)
{
hlFirst.NavigateUrl = strUrl + 1;
hlLast.Enabled = false;
hlNext.Enabled = false;
hlProv.NavigateUrl = strUrl + Convert.ToInt32(curpage - 1);
}
else
{
if (pds.IsFirstPage && pds.IsLastPage)
{
hlLast.Enabled = false;
hlNext.Enabled = false;
hlProv.Enabled = false;
hlFirst.Enabled = false;
}
else
{
hlFirst.NavigateUrl = strUrl + 1;
hlLast.NavigateUrl = strUrl + Convert.ToInt32(pds.PageCount);
hlNext.NavigateUrl = strUrl + Convert.ToInt32(curpage + 1);
hlProv.NavigateUrl = strUrl + Convert.ToInt32(curpage - 1);
}
}
}
RName.DataSource = pds;
RName.DataBind();
} |