Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

MultiSelectList System.ArgumentNullException: 'Value cannot be null. (Parameter 'source')'

$
0
0

I am trying to show files in a list so that they can be selected by the user.

The Append method on Items of type MultiSelectedList is throwing an error: 'Value cannot be null'.

Which value is null? The SelectListItem? Why is it null? It has values! Do I have to instantiate the 'Items' property?

public MultiSelectList Items { get; set; } = null!;private void ListUploadedFiles(){    var uploadPath = Path.Combine(Environment.ContentRootPath, "Upload");    if (Directory.Exists(uploadPath))    {        DirectoryInfo di = new DirectoryInfo(uploadPath);        savedFiles = di.GetFiles().ToList();        foreach (FileInfo file in savedFiles)        {            SelectListItem selectListItem = new SelectListItem(file.Name, file.Name,true);            Items.Append(selectListItem);        }    }}

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>