DataTable dt = ds.Tables[0];
// Clear the listview control
lstItems.Items.Clear();
lstItems.MultiColumn = true;
lstItems.BeginUpdate();
// Display items in the ListView control
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow dr = dt.Rows[i];
// Only row that have not been deleted
if (dr.RowState != DataRowState.Deleted)
{
// Define the list items
ListViewItem lvi = new ListViewItem(dr["ItemNo"].ToString()); //SHOWS
lvi.SubItems.Add(dr["Name"].ToString()); //DOES NOT SHOW
lvi.SubItems.Add(dr["Qty"].ToString()); //DOES NOT SHOW
// Add the list items to the ListView
lstItems.Items.Add(lvi);
}
}
lstItems.EndUpdate();
What the code above shows when running it is the following:
ListViewItem: {12345}
ListViewItem: {56789}
ListViewItem: {12}
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE