QUESTION POSED ON: 08 August 2005
I created a server control that inherits the drop down list control. Basically I wrap up some data access information inside the control. Now all I have to do is drop this control down on a page, set a storedproc and the dropdownlist gets filled. This saves me from having to write all the connection stuff with each drop down I use.
The problem is that when I add this control in design view I get an "Object not set to an instance of an object" dialog box. In the declaration section, I have a reference to a data access business object I wrote. This will take care of running the stored procedure and adding parameters. I also have four methods that mimic the AddParamter methods of the SQLCommand object.
If I override the OnLoad event and create the instance of my DataAccess object there, instead of in the declarations section, everything works fine.
Any ideas why it works when I put it in the OnLoad but not in the declarations? Also, if I put it in the OnLoad, then users can't use this in the Page_Load. They have to use it in the Page_Prerender.
|