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 };
More Related Contents:
- Run async method regularly with specified interval
- How do I create a custom membership provider for ASP.NET MVC 2?
- regex for accepting only persian characters
- “Self Referencing Loop Detected” exception with JSON.Net
- Format of the initialization string does not conform to specification starting at index 0
- ASP.NET Core: Exclude or include files on publish
- How to use non-thread-safe async/await APIs and patterns with ASP.NET Web API?
- Convert System.Drawing.Color to RGB and Hex Value
- How to export a JQgrid data to Excel using c#?
- Absolute path back to web-relative path
- DropdownList DataSource
- Should I store my images in the database or folders? [duplicate]
- Accessing Office Word object model through asp.net results in “failed due to the following error: 80070005 Access is denied.”
- Render HTML as an Image
- Setting dropdownlist selecteditem programmatically
- How to implement “Access-Control-Allow-Origin” header in asp.net
- How can I export a GridView.DataSource to a datatable or dataset?
- Easiest way to parse “querystring” formatted data
- How to add cross domain support to WCF service
- ASP.NET File Upload
- asp.net Button OnClick event not firing
- Recursive TreeView in ASP.NET
- Index (zero based) must be greater than or equal to zero
- Get All Web Controls of a Specific Type on a Page
- Full postback triggered by LinkButton inside GridView inside UpdatePanel
- Unable to find the requested .Net Framework Data Provider. It may not be installed
- GeneralLink in Sitecore
- Change cell color on different values – Gridview
- asp.net web service using office 2010 COM
- Bind Dictionary with list in viewmodel to checkboxes