I’ve got a DataTable with this fields
datatable.Columns.Add("ProductID", typeof(int));
datatable.Columns.Add("LocationList", typeof(List<string>));
datatable.Columns.Add("LocationIds", typeof(List<int>));
datatable.Columns.Add("ProductName", typeof(string));
datatable.Columns.Add("Brand", typeof(string));
datatable.Columns.Add("Price", typeof(decimal));
datatable.Columns.Add("Quantity", typeof(int));
datatable.Columns.Add("Locations", typeof(string));
And I bind it to a ListView
foreach (DataRow row in productsDataTable.Rows)
{
var item = new ListViewItem(row[0].ToString());
for (var i = 1; i < productsDataTable.Columns.Count; i++)
item.SubItems.Add(row[i].ToString());
lvSearchResults.Items.Add(item);
}
I want to bind the List<> fields, so that when a row is selected, I’d be able to get the data from the Lists and do some calculations with it.
Is there any way to do this?
The
ListViewItemhas aTagproperty that you can store data in to retrieve and use later, for example: