How would I go about running a query in asp and storing it in an array. Then with the array go through each record without having to refresh the page every time.
for example
Sub loaddata()
Dim conn As New IfxConnection(connectionstring)
Dim results() As String
Dim i As Integer = 0
conn.ConnectionString = connectionstring
Try
conn.Open()
MsgBox("Made connection!")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Dim cmd As New IfxCommand("Select name from table", conn)
Dim reader As IfxDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
While reader.Read()
results(i) = reader("name")
i += 1
End While
reader.Close()
conn.Close()
End Sub
The results are stored in results(i)
Say I have a button that says next and everytime I want it to go to the next item in the results array. I don’t want the page to refresh. How do i do that?
You need to consider how you are going to set up your page. There are many ways to go about doing this.
If you get all the records on the page load, you can then assign them to their respective controls. To make it appear is if they are on many pages you could use a MultiView control.
Markup
Code-behind
What you want to keep in mind is that each View control has an index inside of the MultiView. So you need a way to keep track of what the active view is. When the user clicks the next button you progress the view by one.
In terms of an MVC application
Controller
View
Every time you click on the ActionLink it will progress through the record set by one.
If the first record is Hello and the second record is World:
/Home/GetRecord/0 – Hello
/Home/GetRecord/1 – World
Sorry that I switched it up to C#, I prefer writing C# by free hand rather than VB. The code is very similar in VB. If you need a converter to go http://converter.telerik.com/.