Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

How to view data from a table with multiple rows

I am using the code below to view countries in a table. How do I modify the code to use a next button to see all the countries in the table? The code below only displays the first record.

For Each xnDonor As Xml.XmlNode In xdDonor.SelectNodes("/Root/CountryTable[Country_ID='" & DonorID & "']")
                DonorID2 = xnDonor.SelectSingleNode("Country_ID").InnerText
                Name = xnDonor.SelectSingleNode("Country").InnerText
                dtDonor.Rows.Add({DonorID2, Name})
            Next
C1CountryOrigin.Text = dtDonor.Rows(0).Item("Country")
 
Thanks,

Victor
Avatar of nepaluz
nepaluz
Flag of United Kingdom of Great Britain and Northern Ireland image

I assume C1CountryOrigin is a label or textbox, so to list all the records you will need to convert the values to a string.
on the other hand, if you want to display them in a combobox, simply set its datasource to the datatable, e.g ComboBox1.DataSource = dtDonor (you may want to set the DisplayMember and the value Member if you choose this route).
In the same way, if you want to display the rows in a datagrid (or even datagridview), simply set its datasource to the datatable, e.g DataGridView1.DataSource = dtDonor (in this case the columns will be autogenerated from the datatable)
Avatar of Victor  Charles

ASKER

Hi,

C1CountryOrigin  is a textbox, I need to see the data in the next row when I click on a Next button. What code do I use to see data in each fow?
ASKER CERTIFIED SOLUTION
Avatar of nepaluz
nepaluz
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Edited above to assign value to textbox.
Did that answer your question?
Hi,

Juast read your post, will test it and get back to you.

Thanks,

Victor
It worked! How do you move to first and last record?
Thanks,
Thank You!