gaponte69
gaponte69

Reputation: 1407

cannot convert from 'string' to 'System.Web.UI.WebControls.ListViewDataItem'

and also cannot add subitems to a ListView control in .net, for example in c# i have this code:

this.listView1.Items.Add(A.Key);
this.listView1.Items[i].SubItems.Add(Convert.ToString(A.Value));
this.listView1.Items[i].SubItems.Add(Convert.ToString(A1[A.Key]))

How to "convert" or use same feature in asp.net page, with idea of adding items and subitems too in a list view control.

Upvotes: 1

Views: 2628

Answers (1)

Brian P
Brian P

Reputation: 1587

When you are adding, you need to either add a listviewitem object or you need to add with value and index.

The sample code in the Microsoft Documentation should help:

https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.listview.items?view=netframework-4.8

Upvotes: 1

Related Questions