1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Asp Paging - How to display different record on each page?

Discussion in 'C#' started by kinsac_2000, Feb 27, 2008.

  1. #1
    Friends I am working on Asp Paging. I want to display 5 records on first page and on otherpages I want to display 10 records. can anyone tell me how to set it?

    Thank you.

    here is my code

    If page = "" Then
    iPageCurrent = 1
    Else
    iPageCurrent = CInt(page)
    End If


    numPerPage = 5

    Dim iPageSize 'How big our pages are
    Dim iPageCount 'The number of pages we get back
    Dim strOrderBy 'A fake parameter used to illustrate passing them
    Dim objPagingConn 'The ADODB connection object
    Dim objPagingRS 'The ADODB recordset object
    Dim iRecordsShown 'Loop controller for displaying just iPageSize records
    Dim I

    iPageSize = numPerPage ' You could easily allow users to change this

    Set objPagingRS = Server.CreateObject("ADODB.Recordset")
    objPagingRS.PageSize = iPageSize

    ' You can change other settings as with any RS
    'objPagingRS.CursorLocation = adUseClient
    objPagingRS.CacheSize = iPageSize
    objPagingRS.CursorLocation = 3
    objPagingRS.CursorType = 3
    objPagingRS.ActiveConnection = cn

    ' Open RS
    'response.write sql
    objPagingRS.Open sql

    ' Get the count of the pages using the given page size
    iPageCount = objPagingRS.PageCount

    ' If the request page falls outside the acceptable range,
    ' give them the closest match (1 or max)
    If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
    If iPageCurrent < 1 Then iPageCurrent = 1

    ' Check page count to prevent bombing when zero results are returned!
    If iPageCount = 0 Then
    Response.Write "No records found!"
    Else
    ' Move to the selected page
    objPagingRS.AbsolutePage = iPageCurrent

    iRecordsShown = 0
     
    kinsac_2000, Feb 27, 2008 IP
  2. adrevol

    adrevol Active Member

    Messages:
    124
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #2
    adrevol, Feb 28, 2008 IP