I need to retrieve the data from the listview for upload

Rusty@VB

New member
Joined
Mar 2, 2006
Messages
1
Programming Experience
1-3
I have a listview on my form displaying 3 columns of data. The user enters data into 3 fields on the form, clicks an Add button and a new row is added to the listview.

My problem is that once the user is done entering their rows into the listview, I need to retrieve the data from the listview for upload.
How do I go about retrieving data from a listview? And how do I convert it from an index to individual strings for each value?

Thanks!
 
What about if you set the checkboxes property to true. Then When the user adds a new item you can set it to be checked. Then When you want the items that have been added in that session you can iterate through the items/subitems collection and get the ones that have been checked. Or just get the checked items collection would be better.After the upload set all the items to unchecked and your ready for your next session.
 
Here's how I would do it, you can take it for what it's worth.

I'd create a class with properties that coreespond to the data you want to display. I'd also include the ID as a property as well.

When loading from the database, create an instance of the class and set the properties, include the ID, this will be importaint later. Create an array with the data to disaplay in the list view. Then create a ListViewItem, passing in the array into the constructor. Then, set the .Tag property of the list view to the class instance. Then add the ListViewItem to the Items collection of the ListView. Keep looping until everything is loaded.

When the user adds a new item, again create a new instance of the class, sett the properties, making the ID 0. Create the ListViewITem, set the array, and the .Tag and add to the ListView.

When you are ready to save, do a for each LVI in ListView.Items... if the ID is 0, then it needs to be inserted into the database, if not, ... well it doesn't.

-tg
 
I see you're using .NET 1.1. You could download the WFC library from my signature and use their ExtendedListView. It supports data-binding just like a DataGrid so you can just put all your data in a DataTable and bind it. Couldn't be simpler. :)
 
Back
Top