Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


ASP Classic - Auto-Numbering and Paging

Posted on 2014-02-02
Medium Priority
Last Modified: 2014-02-08
Hello All

OK, I have a paging system, that using Auto-Numbering.

k = 1
k = k + 1

This is the code that I am using

getPage = Request.QueryString("page")
k = 1
if getPage<>"" then
if getPage=1 then
k = 1
k = getPage +9
end if
end if

Open in new window

Everything works great, until I get to the 3rd page, once I get there, it does not count properly.

This is what I am needing.

1,2,3,4,5,6,7,8,9,10, exc...

Then numbering the records
1-10 = Page 1
11-20 = Page 2
20-30 = Page 3
30-40 = Page 4

You get the point.

To answer you question.
I am using the Database ID# in another section of the page.
However, the Auto Numbering, is used to display an actual 1,2,3,4,count, instead of showing.
200, 201, 202.
When the page just loads, as people are more prone to understand the display of records using the starting of numbers, instead of the ID which can start anywhere, which will make the person wonder if they missed some records or not.

Any idea's on this one?
Question by:Wayne Barron
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
LVL 58

Expert Comment

ID: 39827963
If you are displaying the page number (1,2,3 etc) then why are you adding 9 to the page number
k = getPage +9
Think you best post your db code/sql explaining how you are selecting records
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39828046
CarrzKiss, this is an old time article about page numbering using getrows. http://www.4guysfromrolla.com/webtech/070500-1.shtml

First, using getrows is a lot faster to process

if not rs.bof or not rs.eof then
end if
' close your connections here

Dim iRows, iCols, iRowLoop, iColLoop, iStop
  iRows = UBound(aResults, 2)
  iCols = UBound(aResults, 1)

  If iRows > (iOffset + iStart) Then
    iStop = iOffset + iStart - 1
    iStop = iRows
  End If

  For iRowLoop = iStart to iStop
    For iColLoop = 0 to iCols
      Response.Write aResults(iColLoop, iRowLoop) & " "
    Response.Write "<BR>"
'///// in the body stection
 Response.Write "<P>"
  if iStart > 0 then
    'Show Prev link
    Response.Write "<A HREF=""GetRows.asp?Start=" & iStart-iOffset & _
                   "&Offset=" & iOffset & """>Previous " & iOffset & "</A>"
  end if

  if iStop < iRows then
    'Show Next link
    Response.Write " <A HREF=""GetRows.asp?Start=" & iStart+iOffset & _
                   "&Offset=" & iOffset & """>Next " & iOffset & "</A>"
  end if

Open in new window

LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39828090
Using your current code
dim k, startingRecord
page = 1
startingRecord = 200
if  Request.QueryString("page")<>"" then
     if isnumeric(Request.QueryString("page")) then
          page = Request.QueryString("page")
    end if
end if
startingRecord = (10 * cdbl(page)-1)+1
endingRecord = cdbl(startingRecord) + 10
' sql = "select ID, one,two, three from MyTable where ID >= "&startingRecord&" ID <= "& endingRecord
' to test try response.write sql

if cdbl(page) > 1 then
     prevPage = cdbl(Page)-1
     prevPage = 1
end if

' in the body section

     response.write <a href=""?page="&prevPave&"""><< Prev </a>&nbs;"
     response.write <a href=""?page="&nextPave&""">>> Next </a>"

Open in new window

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

LVL 31

Author Comment

by:Wayne Barron
ID: 39828609
OK guys.
I made up a demo using the paging system that I am using.


Line 103 - 111
These are the lines that generate the Numbers.
(Looking at the demo when run, you will see 2 numbers.
The numbers in the parentheses, Are the Auto-Numbers.
These are the numbers that need to be in order from page to page.
NOW, is this demo, the Database Numbers, are in order.
So please IGNORE them, as we are not concerned with them.)

You should understand it once you look at it.


LVL 31

Author Comment

by:Wayne Barron
ID: 39828646
Fixed INC file, inside of folder.
Download is good now, and fully working.

LVL 31

Author Comment

by:Wayne Barron
ID: 39830491
Hello All;
I am going about this wrong!

What I am going to do instead, is the following:

When a new record is inserted, Look at the last record (IF EXIST)
And do the following.

ComID = 3 (Say there is 3 records)

update tablename set comid=ComID+1

Then I can use the ComID number, as the Com # that the visitors see, instead of the actual number.
This way, each new Com will have a unique ID for that Category.
And then all records will be able to display with the 1,2 ,3, 4 exc...

I am going to close this one down.
Thanks for the suggestions of the Paging scripts and so forth, however, they did not help or assist in what I was trying to do. As shown in the Demo Code that I supplied.

Take care
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39830599
Wayne, I have been overwhelmed with my own programming over the weekend to look at your updated code.

It does sound like this may be more complex than it needs to be.  I have used that core code from 4guys in the past and it works nicely although I had to change my own thinking on how I was doing this in the past.  That method is very fast.

Another option if you are displaying rows of data is to use javascript. I use http://datatables.net/.  Using the same getrows via ajax, I will spit out about 100 rows of data pretty quickly.  When the user gets towards the end, use ajax to build on the array that is already in the browser with another 100 rows of data.  Then the user can sort, search and page as desired without more calls to the server.

It sounds like you have a good handle on this for your own needs.

Best of luck!
LVL 31

Accepted Solution

Wayne Barron earned 0 total points
ID: 39831183
Thanks Scott.
I like that link, however, I am not sure that it would suite the site that I am doing right now. However it might work in the admin section, for dealing with Users and so forth.

I just added in the code that I posted above, and it worked great.
Just tested it, and it took 2 minutes to do the code, and to test.
What it does is the following.

When you post.
It counts the records that exist in the database
If rs.eof then
ctRec = 1 '(This will be the first recorded created)
ctRec = rs("comID")+1  '(this adds 1 to the existing count)
end if

I like it.
Works great for what I need it for.
LVL 31

Author Closing Comment

by:Wayne Barron
ID: 39843924
What I proovided is what I did, in order to get it to work for what I needed it to do.
It is quick and easy to implement, and the things rocks.


Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

618 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