Victor Charles
asked on
Help with moving through records in datatables
Hello,
I've populated two Dropdownlist with two datatables, How do I move throught the records of the datatables while displaying the data in the dropdownLists? I am using VB.NET with ASP.NET.
CmbRec.DataSource = dtReceiver
CmbRec.DataTextField = "Name"
CmbRec.DataValueField = "ReceiverID"
CmbRec.DataBind()
CmbDonor.DataSource = dtDonor
CmbDonor.DataTextField = "Name"
CmbDonor.DataValueField = "DonorID"
CmbDonor.DataBind()
Thanks,
Victor
I've populated two Dropdownlist with two datatables, How do I move throught the records of the datatables while displaying the data in the dropdownLists? I am using VB.NET with ASP.NET.
CmbRec.DataSource = dtReceiver
CmbRec.DataTextField = "Name"
CmbRec.DataValueField = "ReceiverID"
CmbRec.DataBind()
CmbDonor.DataSource = dtDonor
CmbDonor.DataTextField = "Name"
CmbDonor.DataValueField = "DonorID"
CmbDonor.DataBind()
Thanks,
Victor
ASKER
I'm using Button click event to Move Next, Previous,Last and First, what is the propoer syntax for each button click events?
In a combobox? Combobox shows all the records! Anyway, you can maintain an index value in a variable which is incremented in Next click and decremented in Previous click.
ASKER
I know it shows all the records but I only want to see one record at a time. How do I achieve this? Cna you please send me an example of using the index approach.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the code. I meed to use a combobox because when users click on it, I want to display all the data in Receiver and Donor files to give them the capability to change the data from the existing datatable. I will try the code and get back you by tomorrow,
ASKER
Hi,
I'm getting error:currentIndex is not a method on line currentIndex(dtDonor.Rows. Count - 1)
dtDonor = Session("dtDonor")
currentIndex = Session("CurrentIndex")
If dtDonor.Rows.Count > 0 Then
currentIndex(dtDonor.Rows. Count - 1)
Session("CurrentIndex") = currentIndex
CmbRec.Text = dtDonor.Rows(currentIndex) .Item("Nam e")
End If
I'm getting error:currentIndex is not a method on line currentIndex(dtDonor.Rows.
dtDonor = Session("dtDonor")
currentIndex = Session("CurrentIndex")
If dtDonor.Rows.Count > 0 Then
currentIndex(dtDonor.Rows.
Session("CurrentIndex") = currentIndex
CmbRec.Text = dtDonor.Rows(currentIndex)
End If
change
currentIndex(dtDonor.Rows. Count - 1)
to
currentIndex = dtDonor.Rows.Count - 1
currentIndex(dtDonor.Rows.
to
currentIndex = dtDonor.Rows.Count - 1
ASKER
Thank You!
Glad to help :-)
ASKER
I just opened another similar case, hopefully yo can help me solve the next issue.
Loop through the tables?
For i As Integer = 0 to dtDonor.Rows.Count - 1
msgbox dtDonor.Rows(i).Item(0)
Next