P
Pete Kane
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;
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;