-
Data row
Would someone please point out my problem here, and supply the correct code.
=============I think i messed up around the for each statement================
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cnn As New SqlConnection("Data Source=DESKTOP; Initial Catalog=Northwind; Trusted_Connection=yes")
cnn.Open()
Dim da As New SqlDataAdapter("Select * From Customers", cnn)
Dim ds As New DataSet
da.Fill(ds, "Customers")
Dim dr As DataRow
For Each dr In ds.Tables.Item("Customers").Rows
ListBox1.DataSource = dr
ListBox1.DataBind()
Next
End Sub
End Class
-
Re: Data row
well you are rebinding the one list for each data row. That effectively clears what just went in and repopulates the list with the data in the current row. Giving you whatever is in the last row.
try setting the data table as the data source and setting display and value members to the column you want there.