Skip to content

Error “Collection cannot be null. Parameter name: c” in ASP.NET 4.5 WebForm page

January 24, 2013

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.

3 Comments leave one →
  1. Ryan permalink
    January 24, 2013 10:30 AM

    This is exactly the problem I’ve just ran into and likewise have traced it to AutoGenerateRows – however being a newcomer to ASP.NET I still need to find a way for the rows to be generated on the page so that users can enter the needed data (currently I just get an Insert and Cancel option appear) is there a workaround?

    • Deb C permalink
      March 2, 2013 1:03 AM

      I had the same issue Ryan, but when I refreshed the datasource schema, the fields appear. The AutoGenerateRows is still ‘False’.

  2. February 27, 2014 5:35 PM

    You sir, saved my life (or at least a couple of hours hunting this exact same error). Thank you!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: