I am trying to populate a listview from a stored procedure, I can verify all data are being returned just fine but not populated properly in the listview.
I am trying to display 3 columns in my listview, but instead only the first column is showing.
here is my code:
Those are the only records in my table and the represent the ItemNo.
1- Anyone knows what wrong with the code above and not the Name and Qty fields are not showing the listview?
2- How can get rid of the ( ListViewItem: ) caption/header showing in the listview above?
DataTable dt = ds.Tables;
// Clear the listview control
lstItems.MultiColumn = true;
// 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
What the code above shows when running it is the following: