如何在Repeater中设置pagging? [英] how to set pagging in Repeater?
本文介绍了如何在Repeater中设置pagging?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HI,
RowCount = query.First().Count;
for (int i = 0; i < (RowCount / 10) + 1; i++)
{
LinkButton lnk = new LinkButton();
lnk.Click += new EventHandler(lbl_Click);
lnk.ID = "lnkPage" + (i + 1).ToString();
lnk.Text = (i + 1).ToString();
plcPaging.Controls.Add(lnk);
Label spacer = new Label();
spacer.Text = " ";
plcPaging.Controls.Add(spacer);
}
通过使用am diaplaying所有页码,但我想将页码显示限制为10,当我clcik下一个按钮我应该得到翻页如果存在
by using am diaplaying all the page numbers but i want to limit the page number display to 10 and when i clcik next button i should get remaing pages if exist
推荐答案
int maxrecords = 10;
int totalrec = 100;
int pg = 10;
int curpage = 0;
string RBT = "Events";
if (Request.Params.Get("pageid") != null)
curpage = Convert.ToInt32(Request.Params.Get("pageid").ToString());
if (Request.Params.Get("toshow") != null)
RBT = Request.Params.Get("toshow").ToString();
if (pg < curpage)
curpage = pg;
int totpage = totalrec / maxrecords;
if (totalrec % maxrecords != 0)
totpage = totpage + 1;
int pageid = (maxrecords * pg) + 1;
string paginator = string.Empty;
if (curpage > 0)
paginator = "<a href='/urpath/" + RBT + "/" + (curpage - 1) + "/index.htm' class='link1'><img src='/images/previous-bt.gif' alt='Prev' align='absmiddle'/></a>";
for (int i = 0; i < totpage; i++)
{
if (curpage == i)
{ paginator += " " + (i+1); }
else
paginator += " <a href='/urpath/" + RBT + "/" + i + "/index.htm' class='link1'> " + (i + 1) + "</a>";
}
if (curpage < totpage-1)
paginator += " <a href='/urpath/" + RBT + "/" + (curpage + 1) + "/index.htm' class='link1'><img src='/images/next-bt.gif' alt='Next' align='absmiddle' /></a>";
Response.Write(paginator);
使用内联编码会更容易..
和数据库你可以使用PagedDataSource会让它变得更容易;)
希望这有帮助
use inline coding it will be easier..
and for data base u can use PagedDataSource will make it easier ;)
Hope this helps
尝试用谷歌搜索你自己.. :)
有关于 87,200 结果(0.29秒)
这里有一些链接,可能对你有用.. :)
使用ASP.NET Repeater Control进行自定义分页
[ ^ ]
在ASP.NET中使用Repeater控件进行分页 [ ^ ]
允许使用C#在Repeater和DataList中进行寻呼 [ ^ ]
具有分页和排序功能的转发器 [ ^ ]
try to googling your self.. :)
there are About 87,200 results (0.29 seconds)
Here are some links , may be useful for you.. :)
Custom Paging with the ASP.NET Repeater Control
[^]
Paging with Repeater control in ASP.NET[^]
Allow Paging in Repeater and DataList Using C# [^]
Repeater with Paging and Sorting Features[^]
这篇关于如何在Repeater中设置pagging?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文