如何在Repeater中设置pagging

如何在Repeater中设置pagging

本文介绍了如何在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



这篇关于如何在Repeater中设置pagging?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 14:07