0

i have some data in the listview,
maybe someone can help me..

how the script to insert all of the data in the listview into table..
help me please ..

:(


thanks,, sarah :)

2
Contributors
1
Reply
6
Views
6 Years
Discussion Span
Last Post by Mitja Bonca
0

You have to create columns of listView to dataTable (with a bit of a List<T> help), then loop through the listView to fill dataTable:

'lets assume we have 3 column in listView!!

'get columns:
Dim listOfColumns As New List(Of String)()
For Each column As ColumnHeader In listView1.Columns
	listOfColumns.Add(column.ToString())
Next

'create DataTable:
Dim table As New DataTable("myTable")
For Each column As String In listOfColumns
	table.Columns.Add(column, GetType(String))
Next

'fill table with datafrom listView

Dim row As DataRow
Dim i As Integer = 0
For Each item As ListViewItem In listView1.Items
	row = table.NewRow()
	'define for each column in listView:
	row(listOfColumns(i)) = item.Text
	row(listOfColumns(i)) = item.SubItems(1).Text
	row(listOfColumns(i)) = item.SubItems(2).Text
	table.Rows.Add(row)
Next
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.