[RESOLVED] ListView as Detail - database id
http://www.americanavc.com/intranet_logo/listview1.png
I have seen listview controls before that do not show any type of ID. (ie: Items in an order).
So when I delete this row, how does it know which row to delete in my database? There could be many rows with the same exact data but each belonging to a different order. Would there be a hidden column with the record ID in it?
If it is a hidden column, how would I go about this?
I've used this method for returning id's for ComboBox's and Listbox's:
http://www.vb-helper.com/howto_net_listbox_class.html
Thanks for any help in advance.
Re: ListView as Detail - database id
Thanks to an external source, I finally found out about the listview "TAG".
vb Code:
Dim lv1 As ListViewItem = ListView1.Items.Add("!")
lv1.SubItems.Add("A")
lv1.Tag = 195
ListView1.Items.Add("!")
lv1.SubItems.Add("B")
lv1.Tag = 102
Then:
vb Code:
Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
Dim lvi As ListViewItem = ListView1.SelectedItems(0)
If lvi IsNot Nothing Then Debug.WriteLine(lvi.Tag)
End Sub
I am working out a bug on the "SelectedIndex" Command. If I add a Try/Catch it works ok each time. Otherwise I get an error of
"InvalidArgument=Value of '0' is not valid for 'index'. Parameter name: index"
after the first time which works ok.