Also Global:
Dim dvHeader As DataView
Main Topics
Browse All TopicsDears,
1- I have a textbox1 in my aspx page with only one button. The textbox1 is bound to a dataset already filled with data through data adapter. I want to move to the next record in the dataset every time I click the button. How can I,
I tried using this each time the button is pressed, but I failed.
static x as integer
textbox1.text = MyDataset.tables.rows(x)
x= x+1
2- Is it possible to use static variables in the aspx pages, so the variable keep its value.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
In your code, there is an error. when you are using static variables, the value will not change, and any incrementation will not work on that. Instead use a normal variable and increment it.
I go with @L00M
You can use a part of his code:
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
GoNext()
End Sub
Private Sub GoNext()
CurrentRow += 1
If CurrentRow > ds0.Tables(0).Rows.Count - 1 Then CurrentRow = ds0.Tables(0).Rows.Count()
Me.BindingContext(dvHeader
End Sub
to achevie the result you are expecting. Thats more clear and you need not maintain any variables, application takes care of it.
BTW, the reason I put GoNext into a different function is so I could wire up the scroll wheel on the mouse easily:
Private Sub PatientCard_MouseWheel(ByV
If e.Delta < 0 Then
GoNext()
Else
GoPrevious()
End If
End Sub
That can be improved upon, but works ok.
NB
Hey, there is some issue that I too noticed with Global Variables in .NET. As a turnaround, I used a hidden field which was assigned the value of the variable and the value is retrieved wheever required in the post back.
lets say, you have current row=-1 initially, pass on that value to the hidden valriable from CodeBEhind.
When ever you do post back, retrieve the value and again assign it to the hidden field.
Let me check if there are any alternatives available
It would be useful for me also.
Business Accounts
Answer for Membership
by: L00MPosted on 2004-09-01 at 05:51:40ID: 11951732
I accomplish this using a dataview as follows (I have four buttons: Go First, Go Previous, Go Next, Go Last - Let me know if you need further clarification):
).Position = 0
).Position = CurrentRow
- 1 ).Position = CurrentRow
- 1 ).Position = CurrentRow
' Global
Dim CurrentRow As Integer
...
Dim dvHeader As DataView
dvHeader = ds0.Tables(0).DefaultView
...
Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click
GoFirst()
End Sub
Private Sub GoFirst()
CurrentRow = 0
Me.BindingContext(dvHeader
End Sub
Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
GoPrevious()
End Sub
Private Sub GoPrevious()
CurrentRow -= 1
If CurrentRow < 0 Then CurrentRow = 0
Me.BindingContext(dvHeader
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
GoNext()
End Sub
Private Sub GoNext()
CurrentRow += 1
If CurrentRow > ds0.Tables(0).Rows.Count - 1 Then CurrentRow = ds0.Tables(0).Rows.Count()
Me.BindingContext(dvHeader
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
GoLast()
End Sub
Private Sub GoLast()
CurrentRow = ds0.Tables(0).Rows.Count()
Me.BindingContext(dvHeader
End Sub
Neil Brewer