Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. next 10 records?

next 10 records?

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-netdatabasesysadmin
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    matsnas
    wrote on last edited by
    #1

    Just learning asp.net and have a basic question. I have a list of records that I want to display 10 at a time. I have the SQL for it but how should I do in ASP.net to send the offset where I'm currently at? Code:    Private mNofRows As Integer = 10    Private mOffset As Integer = 0    Private Sub AddNavigationHandlers()     Dim vLinkButtonPrev As LinkButton = DirectCast(Me.Form.FindControl("EntryNavigationPrev"), LinkButton)     Dim vLinkButtonNext As LinkButton = DirectCast(Me.Form.FindControl("EntryNavigationNext"), LinkButton)     AddHandler vLinkButtonPrev.Click, AddressOf EntryNavigationPrev_Click     AddHandler vLinkButtonNext.Click, AddressOf EntryNavigationNext_Click     vLinkButtonPrev.Enabled = mOffset > 1   End Sub    Public Sub EntryNavigationPrev_Click(ByVal pSender As Object, ByVal pEventArgs As System.EventArgs)     mOffset -= mNofRows     GetRecords(mOffset, mNofRows)   End Sub    Public Sub EntryNavigationNext_Click(ByVal pSender As Object, ByVal pEventArgs As System.EventArgs)     mOffset += mNofRows     GetRecords(mOffset, mNofRows)   End Sub I was hoping that I could have the member variables set at first time and then use them as shared to retain the value between postbacks, but this doesn't seem to work. Should I be using the tag property of the LinkButtons? Should I be saving the value in a session variable? Should I be saving the value in a hidden control? Should I be saving the value server side using a session object to hold the business tier object with state?

    P 1 Reply Last reply
    0
    • M matsnas

      Just learning asp.net and have a basic question. I have a list of records that I want to display 10 at a time. I have the SQL for it but how should I do in ASP.net to send the offset where I'm currently at? Code:    Private mNofRows As Integer = 10    Private mOffset As Integer = 0    Private Sub AddNavigationHandlers()     Dim vLinkButtonPrev As LinkButton = DirectCast(Me.Form.FindControl("EntryNavigationPrev"), LinkButton)     Dim vLinkButtonNext As LinkButton = DirectCast(Me.Form.FindControl("EntryNavigationNext"), LinkButton)     AddHandler vLinkButtonPrev.Click, AddressOf EntryNavigationPrev_Click     AddHandler vLinkButtonNext.Click, AddressOf EntryNavigationNext_Click     vLinkButtonPrev.Enabled = mOffset > 1   End Sub    Public Sub EntryNavigationPrev_Click(ByVal pSender As Object, ByVal pEventArgs As System.EventArgs)     mOffset -= mNofRows     GetRecords(mOffset, mNofRows)   End Sub    Public Sub EntryNavigationNext_Click(ByVal pSender As Object, ByVal pEventArgs As System.EventArgs)     mOffset += mNofRows     GetRecords(mOffset, mNofRows)   End Sub I was hoping that I could have the member variables set at first time and then use them as shared to retain the value between postbacks, but this doesn't seem to work. Should I be using the tag property of the LinkButtons? Should I be saving the value in a session variable? Should I be saving the value in a hidden control? Should I be saving the value server side using a session object to hold the business tier object with state?

      P Offline
      P Offline
      pphillips99
      wrote on last edited by
      #2

      Hi, The best place for is when calling the SQL in the first instance, for example, your sql/stored procedure should only return 10 records instead of return all the record(s).

      M 1 Reply Last reply
      0
      • P pphillips99

        Hi, The best place for is when calling the SQL in the first instance, for example, your sql/stored procedure should only return 10 records instead of return all the record(s).

        M Offline
        M Offline
        matsnas
        wrote on last edited by
        #3

        I think you missunderstood me. My SQL supports 2 parameters, number of records to return and offset from where to return records. EX: Nof=10, Offset=10 will return records 10-19. I will olny return the number of records that I need from the data-tier. My question is when hitting the linkbutton "next 10 records" and the postback fires, how do I remember the offset variable. For each time I press the "next 10 records" I want to offset counter to increment by 10. In old ASP I would have submitted the Offset parameter as an appended querystring parameter: Ex: <a href="List10Records.asp?intOffset=10">next 10 records</a>. How should I do in ASP.net 2.0?

        A 1 Reply Last reply
        0
        • M matsnas

          I think you missunderstood me. My SQL supports 2 parameters, number of records to return and offset from where to return records. EX: Nof=10, Offset=10 will return records 10-19. I will olny return the number of records that I need from the data-tier. My question is when hitting the linkbutton "next 10 records" and the postback fires, how do I remember the offset variable. For each time I press the "next 10 records" I want to offset counter to increment by 10. In old ASP I would have submitted the Offset parameter as an appended querystring parameter: Ex: <a href="List10Records.asp?intOffset=10">next 10 records</a>. How should I do in ASP.net 2.0?

          A Offline
          A Offline
          Amit Kumar G
          wrote on last edited by
          #4

          use page data source. It has currentindex property. I hope this help you. Amit

          M 1 Reply Last reply
          0
          • A Amit Kumar G

            use page data source. It has currentindex property. I hope this help you. Amit

            M Offline
            M Offline
            matsnas
            wrote on last edited by
            #5

            I should say that I'm not using databinding. I'm surprised that I havn't got more replies to this as I thought that this would be a simple question. I will look at the page data source control but I see this as a more general question, to retain a value between postbacks. I tought the whole idea with code behind was to allow the programmer to utilize more of the same programing thechniques as when writing a WinForms application. I'm surprised that ASP.net cannot handle member variables. Why arenä't these stored and re-initalized by the view state as a controls properties?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups