Record Position

Results 1 to 3 of 3

Thread: Record Position

  1. #1
    Brandon Block Guest

    Default Record Position

    Hi,<BR><BR>Yesterday i´ve got some help with paging a recordset. I wanted to display a certain nummbers of records, from my record set. I worked perfectly! <BR><BR>The result is that i get the specified amount of records... but i also want to be able to control the "start" record... right now records 1 -20 displays or 1 - 40 etc. <BR><BR>What i want is to be able to display record 21 - 40.<BR><BR>Please help me out here <BR><BR>im using a loop to go through the record set<BR>DO WHILE (NOT rsUploads.EOF) AND (intRecCount &#060; vntRecPosition)<BR><BR>Regards<BR>/Brandon

  2. #2
    rajendra Guest

    Default RE: Record Position

    You can do it easily. You can pass the current page number when the page is must have given the next and previous button for navigation. you can check whether you have pressed the next or previous button ( assuming that you have sufficient number of records). You can pass the current page no when the page is submitted. If its next, you can add one to the current page value (requesting the value from the form submitted) and subtract one if it was previous button.<BR>now you can develop a formula to calculate the starting record number. let us say that youre current page number is stored in the variable curpage and you are showing 20 records in one page.<BR>then your formula will be currecord = 20*(curpage - 1) + 1. for example, if you are on page 2, you get the value 20*(2-1) + 1 ie 21. then you can display the variable currecord to show the starting range and add 20 to it to show the ending record no.<BR>that how you can do it.

  3. #3
    Anil Tumati Guest

    Default RE: Record Position

    Hey Dude,<BR><BR>Here is the Code , with which u can do the circus<BR><BR>Assumption<BR>1. Ur ASP File name : MyAspPage.asp<BR>&#060;% <BR>dim rsData,sqlData,Todaydate<BR>dim CurrentPage,NoofRecords,NextPage, PreviousPage,ShowRecordsFrom, ShowRecordsTo, DisplayTextAsTitle<BR><BR>&#039 Checking For the Page Numbers<BR>CurrentPage=Request.QueryString("curren tpg")<BR>if CurrentPage = "" then CurrentPage = 1 end if<BR><BR>&#039 creating the Record Set Object<BR>set rsData = Server.CreateObject("adodb.recordset")<BR>sqlData = "select Data from Tablename "<BR> <BR>&#039Setting all the Record Set Properties <BR>rsData.CursorType = adOpenStatic<BR>rsData.PageSize = 20<BR>shownoofrecords = rsData.PageSize<BR>rsData.Open sqlData, con<BR>NoofRecords = rsData.RecordCount<BR>rsData.AbsolutePage = cint(CurrentPage)<BR>NextPage=cint(CurrentPage)+1< BR>PreviousPage=cint(CurrentPage)-1<BR>if NextPage &#062; rsData.PageCount then NextPage=rsData.PageCount end if <BR>if PreviousPage=0 then PreviousPage=1 end if <BR>ShowRecordsFrom = shownoofrecords*(CurrentPage-1) + 1 <BR>ShowRecordsTo = CurrentPage*shownoofrecords <BR>if ShowRecordsTo &#062; NoofRecords then ShowRecordsTo = NoofRecords end if<BR>DisplayTextAsTitle = ShowRecordsFrom &" to "& ShowRecordsTo &" of "&NoofRecords &#039 This is What ur going to Show as the Title<BR> %&#062;<BR><BR>and ur Looping thur the Rs For the Data and it Should have the Do Loop Like this<BR>&#060;%<BR>do while not rsData.EOF and rowcount&#060;rsData.PageSize <BR> &#039Ur Data Display here<BR>rowcount = rowcount + 1<BR>rsData.MoveNext <BR>loop<BR>%&#062;<BR><BR>This is the Code That U are going to add at the end of the Page - For navigation to Next and Previous Pages<BR>&#060;%if cint(rsData.PageCount) &#062; 1 then<BR>if CurrentPage &#062; 1 then %&#062;<BR>&#060;a href = "MyAspPage.asp?currentpg=&#060;%=PreviousPage%&#06 2;" &#062; Previous&#060;/a&#062;<BR>&#060;%end if <BR>if cint(CurrentPage)+1 &#060;= cint(NextPage) then%&#062;<BR>&nbsp;&nbsp;&nbsp;&#060;a href = "MyAspPage.asp?currentpg=&#060;%=NextPage%&#06 2;" &#062; Next&#060;/a&#062;<BR>&#060;%end if<BR>end if<BR>%&#062; <BR>

Posting Permissions

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