I am not sure why I am getting this error.
How can I dynamically set the error provider for a control?
if (errorList.Count == 0)
{
return true;
}
else
{
foreach (ErrorEntity ee in errorList)
{
if (ee.InError)
{
Control[] ctl = this.Controls.Find(ee.FieldName, true);
if (ctl != null)
{
errorProvider.SetError(ctl[0], ee.ErrorMessage);
}
}
}
}
My guess is that
is returning an empty collection, and not a null.
So when you check for null, you should also check for empty (ie: Count==0)