Geeks With Blogs

Create Fun Things - Samer's Developer Blog Development Blog for C#, .NET and Obj-C

So I came across this fun error today, which stopped me from being productive for about 2 hours. Unfortunately my search on the internets did not prove to be useful, so I had to manually dig through every part of my code to understand what was going wrong. Seriously, could the error be less generic?

The stack trace indicated that the error was coming from the ListView databinding—which was of some help ,but not much, since the page I was getting the error on has about 10 listviews (It’s a portal type page.)

I tried working out what was recently changed and the biggest thing is that I was now pulling records from a custom DataObjectMethod that pulled data from a cached custom object that I built on request. When I switched my ObjectDataSource back to the original method, the problem went away. So this lead me closer to figuring out what was going on.

So the object that the ObjectDataSource was pulling from was a custom composite object, that held Lists of several types of other business objects. Turns out what was happening is that not all of the objects were being initialized, since some are dependent on gender. So the ListView that was throwing the exception over and over was the one dependent on the gender of the person currently selected.

I added a null check and initialized it if it was null, and now the error went away. Success!

Posted on Sunday, August 16, 2009 12:22 PM | Back to top

Comments on this post: “Value cannot be null. Parameter name: container”

# “Value cannot be null. Parameter name: container”
Requesting Gravatar...
Value cannot be null. Parameter name: container
Left by Manish Kumar on May 30, 2013 6:22 AM

# re: “Value cannot be null. Parameter name: container”
Requesting Gravatar...
set your spgridview.EnableViewState to "false"
Left by kikohoh on Feb 05, 2016 10:56 AM

Your comment:
 (will show your gravatar)

Copyright © samerpaul | Powered by: