我应该如何编写该寻呼? [英] How should i code this paging?

查看:120
本文介绍了我应该如何编写该寻呼?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在挣扎了一些代码,寻呼的一对夫妇,现在天(YES!天),但不能让它正常工作,可能是因为我没有对这类问题的经验,但

I've been struggling with some code for a paging for a couple of days (YES! days) now but can't get it to work properly, probably because I don't have any experience on this kind of problems yet.

我想要做的应该是这个样子的分页:

the paging I'm trying to do should look something like this:

1 2 3 4 5 6 ... 101

1 2 3 4 5 6 ... 101

当我在5号点击我会喜欢它显示像这样的数字:

When i click on number 5 i would like it to display the numbers like this:

1 ... 3 4 5 6 7 ... 101

1 ... 3 4 5 6 7 ... 101

当我在最后几页我希望它类似于第一个:

when I'm at the last couple of pages i want it to look similar to the first one:

1 ... 96 97 98 99 100 101

1 ... 96 97 98 99 100 101

大胆的号码是您正在浏览的页面。

The bold number is the page that you're currently viewing.

我想点只出现在有700多页可用如果不是它应该看起来像一个正常的页面看起来像:

I want the dots to appear only when there is more than 7 pages available, if not it should look like a normal paging would look like:

1 2 3 4 5 6 7

1 2 3 4 5 6 7

现在,我想每页显示10个项目。

Right now i want to display 10 items per page.

语言我想使用的是C#(ASP.NET),并想,后来就使这个用户控件(我应该在哪里设置的属性TotalNumberOfItems,ItemsPerPage等等)。

The language i want to use is C# (ASP.NET) and would like to, later on make this a usercontrol (Where i should set the properties TotalNumberOfItems, ItemsPerPage and so on).

问题:
我怎样写上正确的位置代码环出的数字? :)

The question: How do i write the code to loop out the numbers on the correct places? :)

推荐答案

怎么样(使它大胆有点伪码,因为我不知道是什么UI你是.. 。)

How about (Make it Bold is somewhat psuedoCode cause I don't know what UI you're in...)

   private static string BuildPaging(int pageNo, int pageCount)
   {
      StringBuilder sb = new StringBuilder();

      for(int i = 1; i < pageCount; i++)
      {
         if (i == pageNo) 
             sb.Append([Make it Bold] + i.ToString("0") + [Make it not Bold]);
         else if (1 > pageNo - 3 && i < pageNo + 3)
             sb.Append(i.ToString("0"));
         else if ((i == 2 && pageNo > 4) ||        
                  (i == PageCount - 1 && pageNo < PageCount - 2))
             sb.Append("...");
      }
      return sb.ToString();
   }



唯一的事情就是如何使它大胆(取决于你是否是在的WinForms和ASP.Net ...
...并添加东西,使之成为可点击的链接...

Only thing is how to make it bold (Depends on whether you're in WinForms or ASP.Net... ... And add stuff to make it a clickable link...

这篇关于我应该如何编写该寻呼?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆