Error “Collection cannot be null. Parameter name: c” in ASP.NET 4.5 WebForm page
I was upgrading an ASP.NET 3.5 site to 4.5 and got this error: “Collection cannot be null. Parameter name: c“. It occurs just after page databinding and I couldn’t set any debug point in my code. On top of that Google search for this error didn’t give me much useful information.
I tried to narrow down by removing most databound controls (Griview, Formview, DetailsView) in aspx file and reviving one by one. I finally cornered a DetailsView as the culprit. The error is gone when I added “AutogenerateRows=”False”” to the DetailsView.
I guess the default behaviour of ASP.NET 4.5 has been changed regarding DetailsView property though I am not sure why this suddenly became an issue when 3.5 site was just working fine. Anyway, I hope this can help other developers.