Home > Ask the Microsoft .Net Development Experts > ASP.NET and Web Development Questions & Answers > Drop down list server control creates error message
Ask The Win Development Expert: Questions & Answers
EMAIL THIS

Drop down list server control creates error message

Mark Belles EXPERT RESPONSE FROM: Mark Belles

Pose a Question
Other Win Development Categories
Meet all Win Development Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
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.


>
Without having the code to look at, it would be nearly impossible to determine the exact cause of the exception.

I would recommend that you review the Control execution lifecycle. If you have the MSDN Library installed, you can find this using the index and the query 'Control Execution Lifecycle', or by simply searching Google for the same phrase.


Do you have comments on this Ask the Expert question and response? Let us know.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
ASP.NET
Top ASP.NET expert advice from Danny Cazzulino
Access VB .NET Windows control on client side
How to retrieve the MAC address of a client using ASP.NET
How to sort a dropdown list in ASP.NET
Accessing session variables in different pages
Automatically closing a .exe
Accessing a control on an independent application
Checking input by character to verify validity
Referencing an old Crystal Reports version
Redirecting results to a text file

Visual Basic .NET
Access VB .NET Windows control on client side
Converting floating values to byte form
Datagrid issue: 'onselection' is not populating
Read data from parallel port
What is the use of these constructors?
Give me an ODBC connect, with SQL authentication
Converting EXE-files to VB components
Generating classes like we did in VB6
Manipulating text through VB.NET
Converting Windows applications to VB .NET

ASP.NET and Web Development
Top ASP.NET expert advice from Danny Cazzulino
Access VB .NET Windows control on client side
Take care with InitializeComponent
Calling via command prompt from ASP.NET
Screen capturing
How to retrieve the MAC address of a client using ASP.NET
How to sort a dropdown list in ASP.NET
Accessing session variables in different pages
Automatically closing a .exe
Accessing a control on an independent application

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Windows Development - White Papers, News and Expert Advice
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts