Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ListView Items Not Showing
Message
From
26/09/2010 16:17:28
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01475624
Message ID:
01482791
Views:
48
I didn't notice that from your previous post (that you neglected to add any columns) ... sorry.

The reason it doesn't throw an exception is because if your ListView has a different View (other than View.Details), the Items *will* show up. The Details view is the only one that displays the Items in columns.

~~Bonnie


>This was a couple of months ago, but I just ran into it again.
>
>I never added a column to the listview, so even though the items collection was being populated, the item never showed up.
>
>You would think the the control would throw an exception if you try to add items with no rows defined.
>
>K
>
>
>
>>Your code looks ok Kevin ... are you sure you have data in those rows? Have you stepped through this code in the debugger? If so, check the lstTribals.Items.Count after you add a new item.
>>
>>~~Bonnie
>>
>>
>>>I have a ListView on my form. It's View property is set to Details. I'm loading from a dataset:
>>>
>>>
>>>foreach (DataRow Row in dsTribals.Tables[0].Rows)
>>>{
>>>    if (Row["Price"] != DBNull.Value)
>>>    {
>>>        PartPrice = (decimal)Row["Price"];
>>>    }
>>>    ListViewItem NewItem = new ListViewItem(Row["TribalNumber"].ToString());
>>>    NewItem.SubItems.Add(PartPrice.ToString());
>>>
>>>    lstTribals.Items.Add(NewItem);
>>>}
>>>
>>>The code runs, but I see nothing in the list.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform