10 records per page

Results 1 to 4 of 4

Thread: 10 records per page

  1. #1
    Ken Renwick Guest

    Default 10 records per page

    I am new to ASP and am trying to develop a page that shows 10 database records at a time.<BR>I have used the coding which appears at http://www.4guysfromrolla.com/webtech/121298-1.shtml as a basis.<BR><BR>However there are too many records for it to be practicable to scroll through each page hitting the next button. I have therefore set up an index page which passes an alpha parameter to the page (eg hit "a" and all records beginning with "a" are displayed).<BR><BR>This works fine for the first page but when you hit the "next" button subsequent pages fail because the alpha parameter is not maintained and passed with the instruction to go to the next page.<BR><BR>Hitting the "next" button needs to pass both parameters for the page to display properly. ie alpha and next page number.<BR><BR>Could someone please explain how to do this.<BR><BR>Here is the SQL I am using and the database is Access<BR><BR>Dim strSQL<BR>strSQL = "SELECT Trade.Business1, Trade.ID, Left([Business1],1) AS Alpha FROM Trade WHERE Left([Business1],1)=" & strAlpha<BR><BR>Thanks in advance<BR><BR>Ken Renwick

  2. #2
    Join Date
    Dec 1969
    Posts
    308

    Default RE: 10 records per page

    When you click the next button to increment the pages you can also pass querystring variables to the script. I usuall use JavaScript to do this.<BR><BR>Here is an example of how i determine what buttons to display and what variables to pass:<BR><BR>&#060;% <BR><BR> &#039Display Next / Prev buttons<BR> if CurPage &#062; 1 then<BR> if selection = "true" then<BR> Response.Write("&#060;INPUT TYPE=BUTTON VALUE=PREV ONCLICK=""document.location.href=&#039show.asp?YOU RVARIABLE=" & YOURVARIABLE & "&curpage=" & curpage - 1 & "&#039;""&#062;")<BR> else<BR> &#039We are not at the beginning, show the prev button<BR> Response.Write("&#060;INPUT TYPE=BUTTON VALUE=PREV ONCLICK=""document.location.href=&#039show.asp?cur page=" & curpage - 1 & "&#039;""&#062;")<BR> end if<BR> End If<BR><BR> if CInt(CurPage) &#060;&#062; CInt(TotalPages) then<BR> &#039We are not at the end, show a next button<BR> if selection = "true" then<BR> Response.Write("&#060;INPUT TYPE=BUTTON VALUE=NEXT ONCLICK=""document.location.href=&#039show.asp?YOU RVARIABLE=" & YOURVARIABLE & "&curpage=" & curpage + 1 & "&#039;""&#062;")<BR> else<BR> &#039We are not at the beginning, show the prev button<BR> Response.Write("&#060;INPUT TYPE=BUTTON VALUE=NEXT ONCLICK=""document.location.href=&#039show.asp?cur page=" & curpage + 1 & "&#039;""&#062;")<BR> end if<BR> End If %&#062;<BR><BR>Hope that gets you headed in the right direction.<BR>--brad

  3. #3
    Ken Renwick Guest

    Default RE: 10 records per page

    Thanks Brad,<BR>I had been trying to do along the lines that you suggest but couldn&#039t get the syntax right.<BR><BR>However I keep getting this error message now:<BR><BR>Microsoft VBScript runtime error &#039 800a01f4&#039 <BR><BR>Variable is undefined: &#039selection&#039<BR><BR>According to the line number the error is here:<BR><BR>if CInt(CurPage) &#060;&#062; CInt(TotalPages) then<BR>&#039We are not at the end, show a next button<BR>if selection = "true" then<BR><BR>and now I&#039m lost altogether especially since the similar code earlier (for the previous button) seems to work OK.<BR><BR>Could you point me further in the right direction please.<BR><BR>Regards<BR><BR>Ken<BR>

  4. #4
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: 10 records per page

    Do you have Option Explicit at the top of your ASP page? I&#039d wager so; I&#039d also wager that you don&#039t have:<BR><BR>Dim selection<BR><BR>anywhere. Usually when you get that error that is the reason.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •