.mdf Database and ListView
How would one iterate through a collection of items in a column from a table in a database. Then display that in a listView.
I know how to adequately use a ListView object. However, I don' know how to iterate through items in a table from a database. How would I go about doing this?
Re: .mdf Database and ListView
A DataTable has rows and columns and to traverse data with rows and columns you pretty much always use nested loops. The outer loop would go through the rows of the table and the inner loop would go through the columns of the current row. Given that a ListView with its View set to Details also has rows and columns, there's a very close correspondence between the two.
That said, far too many beginners choose to make their lives difficult by using a ListView to display data from a database when they should not. More often than not you should be using a DataGridView or some other genuine grid control, which the ListView is not. If you use a DataGridView then you can take advantage of data-binding, so there's no need for any code to transfer the data from the table to the grid and back again.
Re: .mdf Database and ListView
Very helpful advice, thank you for your prompt and informative response.