Solved

asp.net paging

Posted on 2011-09-14
3
197 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

861 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now