I am converting an ASP.NET MVC application to ASP.NET MVC 2, and I get the following error:
Cannot apply indexing with [] to an expression of type 'System.Web.Mvc.IValueProvider'
Here is the code:
public static void AddRuleViolation(this ModelStateDictionary modelState,
RuleViolation error,
FormCollection collection)
{
modelState.AddModelError(error.PropertyName, error.ErrorMessage);
modelState.SetModelValue(error.PropertyName,
collection.ToValueProvider()[error.PropertyName]);
}
How can this be remedied?