This project is read-only.

Creating a user control

Jun 1, 2010 at 12:13 AM


I am trying to create a user control that uses a subdomain.  When I drag the control onto a form I get:

Failed to create component. System.ArgumentNullException : Value cannot be null.

Is this by design?  Any help would be very much ppreciated.



Below is the only code in the control.

namespace AddEditDataGrid
    public partial class UserControl2 : UserControl
        public UserControl2()
            ConfigurationValues.GetInstance().ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];

            SubDomain subDomain = new SubDomain();
            subDomain.AddSelectCommand(new CustomersSelectAll());
            subDomain.RunSelectCommands();   *** This line causes an exception at design time ***


Jun 1, 2010 at 1:27 PM

I will have to setup and run an example later, but you do not really want to be hitting your database at design time. There is a property "DesignMode" that will tell you if you are in design mode or not. You should wrap this code in it.