Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

asp.net paging

Posted on 2011-09-14
3
Medium Priority
?
210 Views
Last Modified: 2012-05-12
I have attached paging in asp.net/vb.net
and it lists all of page number. what I prefer is
showing as follow:

<< 1 2 3 4 5 >>

so it only shows 5 at a page.

Is that possible?

For i = 1 To TotalRecordCountClient
                    SelectedPartNo = SingleItem(Category, i)
                    If i = QueryStringRowNumber Then
                        p.Append("<font size=""2"">" & " " & i & " " & "</font>")
                    Else
                        p.Append("<a href=""http://www.abc.com/Default.aspx?PL=Sitemap&RowNumber=" & i & "&id0=" & Category & "&PartNo=" & SelectedPartNo & """><font color=blue>" & i & "</font></a>" & " ")
                    End If
                Next

Open in new window

0
Comment
Question by:Webboy2008
  • 2
3 Comments
 
LVL 16

Expert Comment

by:disrupt
ID: 36540088
You can do something like this below, you will need logic though to determine what page you are in and if it is less than TotalRecordCountClient by at least five if not return the difference and append that to the legnth.
int length = 5;
        int start = 1;

        protected void Page_Load(object sender, EventArgs e)
        {
            IEnumerable<int> next = Enumerable.Range(start, length).Select(x => x);

            foreach (int num in next)
            {
                Response.Write(num + "<br/>");
            }

        }

Open in new window

0
 

Author Comment

by:Webboy2008
ID: 36540102
can you send me completed working codes with like << 1 2 3 4 5 >>?
If I copy/paste your codes to there, I don't think it is working.
0
 
LVL 16

Accepted Solution

by:
disrupt earned 2000 total points
ID: 36540106
My code wasn't intended to copy/paste it was to start you out and build the 1-5 page once you click on a 1-5 page you need to pass the current page number into start which will give you the next five and so on....
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question