I have a Model
which contains properties and ICollection
of files.
[Required]
public int SerialNo { get; set; }
public Type Type {get; set;}
[Required]
public int TypeId
public virtual ICollection<Files> Files { get; set; }
Now, I am on my Edit Screen, and if Model State is not valid I pass my object again to the view. Like this:
if (!ModelState.IsValid)
{
return View(MyClass);
}
I am getting System.ArgumentNullException: Value cannot be null.
for Files Collection. How can I attach my Files Collection again with my object?
Modified: Use of Collection Files:
@foreach (var item in Model.Files)
{
<p> @item.Location </p>
}
The problem is File is Null
.