Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Another ListView problem
Message
 
To
All
General information
Forum:
ASP.NET
Category:
Forms
Title:
Another ListView problem
Miscellaneous
Thread ID:
01182698
Message ID:
01182698
Views:
68
Hi All, I'm having a problem retrieving subitems from a listview using the string indexer method, my code for filling the lv is as shown below
// take it as read there is data in the dataset.
 foreach (DataRow dr in this.dsArt39Benefics.Tables[0].Rows)
 {
    lvi = new ListViewItem(dr["BenName"].ToString());
    lvi.SubItems.Add(dr["Ben_AddrLine1"].ToString());
    lvi.SubItems.Add(dr["Ben_AddrLine2"].ToString());
    lvi.SubItems.Add(dr["Ben_AddrLine3"].ToString());
    lvi.SubItems.Add(dr["Ben_AddrLine4"].ToString());
    lvi.SubItems.Add(dr["CreateDate"].ToString());
    lvi.SubItems.Add(dr["CreateUser"].ToString());
    lvi.SubItems.Add(dr["AmendDate"].ToString());
    lvi.SubItems.Add(dr["AmendUser"].ToString());
             
    this.lvBeneficialOwnersNameAddress.Items.Add(lvi);

}
Later in the code I try to retrieve a value like this
ListViewItem lvi = this.lvBeneficialOwnersNameAddress.SelectedItems[0];

string s = lvi.SubItems["AmendUser"].Text;
the string s is always null, however, if I do it this way (the code below) it works, anyone know why ?
ListViewItem lvi = this.lvBeneficialOwnersNameAddress.SelectedItems[0];

string s = lvi.SubItems[8].Text;
Regards,
Peter J. Kane



Pete
Next
Reply
Map
View

Click here to load this message in the networking platform