Error: Cannot implicitly convert type 'void' to 'System.Collections.Generic.List'

After creating the List<Item> you're immediately calling Add on it, which is a method returning void. This cannot be converted to the type of ItemList.ItemList.

You should do this instead:

var list = new List<Item>();
list.Add(item);
ItemList.ItemList = list;

You can't do that because the Add function returns void, not a reference to the list. You can do this:

mycontrol.ItemList = new List<Item>();
mycontrol.ItemList.Add(item);

or use a collection initializer:

mycontrol.ItemList = new List<Item> { item };

new List<Item>().Add(item);

This line returns void.

Try:

var list = new List<Item>();
list.Add(item);
ItemListt.ItemList = list;

Tags:

C#

Asp.Net