Using a file upload c# webform to insert some records into database. Any errors I get I am adding to a list. After all records inserted i use linq to see if the list of errors has anything in it if it does. I write it to another list and then foreach record in this list I write out the error in a label on screen. Get the error in the linq to list that Object not set to an instance of an object.
List<Cups> errors = FDloads.Where(c => c.DataErrors.Count > 0).ToList();
if (errors.Count > 0)
{
Label1.Text = "Errors:";
foreach (Cups err in errors)
{
Label1.Text += "<br/>" + err.Lion + "," + err.Value;
}
}
else
{
Label1.Text = "Success.";
}
Errors happens write at linq line when I write the errors count in list FDloads to a new list and if it contains anything do this, if not do this…
Please try: