473,698 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Classic ASP Datagrid with Paging

Fary4u
273 Contributor
Hi

i've done the Datagrid view but only problem with displaying pages
here is the code for Datagrid
Expand|Select|Wrap|Line Numbers
  1.     <%
  2.     Dim I, iPageSize
  3.  
  4.     iPageSize = 9 'Change pages
  5.     Dim arrPhotoNames
  6.     arrPhotoNames = Array("1", "2", "3", "4", _
  7.                       "5", "6", "7", "8", _
  8.                       "9", "10", "11", "12", _
  9.                       "13", "14", "15", "16",_
  10.                       "17", "18", "19", "20", _
  11.                       "21", "22", "23", "24", "25")
  12.  
  13.  
  14.     %><table border="1" ><tr><%
  15.  
  16.  For I = LBound(arrPhotoNames) To UBound(arrPhotoNames)
  17.  
  18.         %><td align="center"><%
  19.         Response.Write arrPhotoNames(I)
  20.         %></td><%
  21.         ' change this number but next number is less then previouse 
  22.         ' example 5 = 4 or 4 = 3 it's mod function
  23.         If I Mod 3 = 2 Then
  24.                 %></tr><tr><%
  25.             End If
  26.  
  27.  Next 'I
  28.     %>
  29.  
what i would like to do now showing paging for display
1st 9 records on 1st page ( 1,2,3,4,5,6,7,8 ,9 )
2nd 9 records on 2nd page ( 10,11,12,13,14, 15,16,17,18 )
3rd 9 records on 3rd page ( 19,20,21,22,23, 24,25 ) & rest

this page will be automatically
important thing with this code is you can change the row & col with MOD Method

how can we show the paging ?
any body knows how to fix this code ?

thanks 4 reply & regards
Fary
Sep 1 '09 #1
4 9769
Fary4u
273 Contributor
any chance how to get around wd ths problme ?
Sep 2 '09 #2
Fary4u
273 Contributor
i think so it's not possible am i rite ?
Sep 4 '09 #3
jhardman
3,406 Recognized Expert Specialist
it's possible, there's just no built-in way to do it. To show a certain number of records on a page you would need to use "for x = 0 to 8" to loop through the records instead of the common method of "do until objRS.eof", but then you would need to clarify that if the end of the records are reached you need to exit the loop: "if objRS.eof then exit for".

To open a record list in the middle, use the objRS.move() command. For example, I might put a link with something like
Expand|Select|Wrap|Line Numbers
  1. <a href="samepage.asp?page=2">next 9 records</a>
and right before I start reading the records I would put something like this:
Expand|Select|Wrap|Line Numbers
  1. dim firstRecord
  2. if request(page) <> "" then
  3.    if cint(request(page)) > 1 then
  4.       firstRecord = cint(request(page)) * 9 - 9
  5.       objRS.move(firstRecord)
  6.    end if
  7. end if
  8.  
  9. for x = 0 to 8
  10.    '...
Does this make sense?

Jared
Sep 6 '09 #4
Fary4u
273 Contributor
Hi Jared

your 100% rite coz i've done the coding but slightly different way but now only problem with last page & it's giving me error ?

Expand|Select|Wrap|Line Numbers
  1. Error Type:
  2. Microsoft VBScript runtime (0x800A0009)
  3. Subscript out of range: '9'
  4. /desktop/asp download/getrow.asp, line ( problem is in this code ) 
but i find another problem which is very rare ? & makes me confused ?
when it's shows 9 records it's takes 1 extra vaule : (

Expand|Select|Wrap|Line Numbers
  1.     iRecFirst   = (iPageCurrent-1)
  2.     iRecLast    = iRecFirst + iPageSize
  3.     iFieldFirst = LBound(arrPhotoNames, 1)
  4.     iFieldLast  = UBound(arrPhotoNames, 1)
  5.  
does it make any sense ? thanks for you reply.
here is rest of the code.

Expand|Select|Wrap|Line Numbers
  1.  
  2.       arrPhotoNames.PageSize = iPageSize
  3.       arrPhotoNames.CacheSize = iPageSize
  4.       iPageCount = arrPhotoNames.PageCount
  5.  
  6.           If iPageCurrent > iPageCount Then
  7.              iPageCurrent = iPageCount
  8.         end if
  9.         If iPageCurrent < 1 Then
  10.              iPageCurrent = 1
  11.         end if
  12.  
  13.     If iPageCount = 0 Then
  14.         Response.Write "No Records found"
  15.     Else
  16.         arrPhotoNames.AbsolutePage = iPageCurrent
  17.  
  18.         iRecordsShown = 0
  19.     Do While iRecordsShown < iPageSize and not arrPhotoNames.EOF
  20.  
  21. Executed Code ------------------------------------
  22.  
  23.       iRecordsShown = iRecordsShown 
  24.  
  25.     Loop
  26.  
  27.     End if
  28.  
  29. If iPageCurrent > 1 Then
  30. %>
  31. <a HREF="getrow.asp?intCatalogID=<%= Server.URLEncode(strParam) %>&page=<%= iPageCurrent - 1 %>
  32. <%
  33.  
  34. End If
  35. For I2 = 1 To iPageCount
  36. %>
  37.  
  38. <a href="getrow.asp?intCatalogID=<%= Server.URLEncode(strParam) %>&page=<%= I2 %>| <%= I2 %> |</a>
  39. <%
  40. Next 'I2
  41.  
  42. If iPageCurrent < iPageCount Then
  43. %>
  44. <a HREF="getrow.asp?intCatalogID=<%= Server.URLEncode(strParam) %>&page=<%= iPageCurrent + 1 %>
  45.  
  46. <%
  47. End If
  48. %>
  49.  
Sep 7 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3569
by: RelaxoRy | last post by:
sqlConnection1.Open(); myReader = sqlCommand1.ExecuteReader(); DataGrid1.DataSource = myReader; DataGrid1.DataBind(); myReader.Close(); sqlConnection1.Close(); The Datagrid populates fine. I'm styling it on the HTML page. I configure the DataGrid for paging through the property builder fine. I AllowCustomePaging=true;. The page loads fine but it only shows "1"
3
8684
by: Joseph D. DeJohn | last post by:
I am trying to get pagination working on a datagrid. Can anyone point me to a resource for help on this? I'm not sure if custom paging is the best option or not.
2
2253
by: enak | last post by:
I can not get my datagrid to page. I have a datagrid that I can sort 2 of the columns. This works great. I added paging and when I display the dg it shows 5 pages. (I am showing page numbers at the bottom of the dg.) When I click on the pages nothing happens until I get to the last page. Then and only then is the last page displayed. If I go back through the pages the second to last page displayes the first page again.
2
2579
by: RJN | last post by:
Hi Sorry for posting again. I have a datagrid which is put inside a div tag to make it scrollable. I need to page the datagrid. The page numbers appear at the bottom of the datagrid and has to be scrolled down completely to see the page number links. The page number should always be visible outside the scroll bar. Basically I want to create the paging links dynamically and on click of this it should fire PageIndexChanged event.
6
1813
by: Shawn | last post by:
Hi. I already have a datagrid where I'm using paging. I have a stored procedure that fills a temp table with 200-500 rows and then sends back 10 records at the time. When I go to page 2 the SP fills the temp table again and returns rows 10-19. The temp table is dropped after each call to the SP, so it has to be created and filled every time the user changes page in the datagrid. My question is this: Would it be more efficient to...
2
1859
by: Axel Dahmen | last post by:
Hi, I'm using a DataGrid control to show a table's content with paging. For navigation through the pages I'm using the DataGrid's intrinsic navigation section. My problem: The DataGrid navigation links use JavaScript to jump between pages. I want them to use standard hyperlinks providing the page number in some URL parameter so that I can copy the hyperlink elsewhere.
5
2785
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go to the database to get the next page. Is there a way to use the dataset to allow us to read back and forth in it instead of going back to the database to get it? Thanks,
0
1340
by: Pat | last post by:
I have 3 Datagrid nested. Master Details Child The master has paging (And i'm using the paging inbuilt in the Datagrid) in the Master DataGrid you select a linkbutton(using commandname) and it populates the data in the Details DataGrid (I'm using Dim Filter As String = CStr(dtgMaster.DataKeys(dtgMaster.SelectedIndex)).Replace("'", "''") to filter btw the Datagrids)
2
1957
by: | last post by:
Is it possible to use IE transition effects (e.g. progid:DXImageTransform.Microsoft.Fade(Duration=2)">) to smooth "classic" (IE non-ATLAS) datagrid paging? How do you wire up the transition effect to fire with each paging event, (versus page load, which won't show on paging event.) I'm pretty sure this is possible: unless Jeff Prosise dummied up his entire demo, he had something like this miming ATLAS-ish effects at the Tech Ed...
0
8671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9152
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9016
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8856
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4613
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.