next 10 records?
-
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? -
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?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).
-
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).
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? -
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?use page data source. It has currentindex property. I hope this help you. Amit
-
use page data source. It has currentindex property. I hope this help you. Amit
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?