Kevin,
Thanks for the response. I'm not getting the error message now at design time. When I run the webform there is no data in the dropdown. Do I have to somehow register my business object with the page? If so, how would I cast the page object within the dropdown to the mmBusinessWebPage page? I've attempted this, but the ParentForm property is an undefined value at runtime.
protected Facility oFacility;
protected mmBusinessWebPage ParentForm;
public JdaFacilityDropDownList()
{
this.ParentForm = this.Page as mmBusinessWebPage;
if (mmAppBase.IsRunning)
{
this.ClientCode = "BSC";
this.oFacility = (Facility) this.ParentForm.RegisterBizObj (new Facility());
this.BindingSource = "Facility";
this.BindingSourceDisplayMember = "Descr";
this.BindingSourceValueMember = "Fac_Num";
this.oFacility.GetFacilitiesForClientCode(this.ClientCode);
}// if (mmAppBase.IsRunning)
}//public JdaFacilityDropDownList()
>Jim,
>
>> I have a dropdown list that is going to retrieve data and populate the dropdown. The dropdownlist is a basic class inherited from the Mere Mortals Dropdownlist control. The problem I am having is that if I place code in the constructor to populate the dropdown and place the control on a webform, the control does appears as a gray box and it says Error Creating Control in red letters. If I put my mouse over the control the tooltip says "object reference not set to the instance of an object". This is, of course, in design mode. The code I am using for the dropdown list class is below.
>
>This is a Visual Studio "issue" (although it IS by design). Visual Studio runs your contorl's constructor at design time. If it can't find the objects it needs at design time, you will see the error you mentioned.sically
>
>The MM .NET Help topic "Why do I get errors when I open a component in design mode?" tells you how to get around this problem. Basically, you need to bracket your constructor code with a check that only runs your code if you are running in design mode. .NET has a built-in DesignMode property that is SUPPOSED to provide this information for you, but it doesn't work during object construction. That's why we have added the IsRunning property to MM .NET.
>
>So, your code will look something like this:
>
>
>/// constructor - retrieves desired facility data based on properties.
>/// </summary>
>public JdaFacilityDropDownList() : base()
>{
> //
> // TODO: Add constructor logic here
> //
> if (mmAppBase.IsRunning)
> this.ClientCode = "BSC";
> this.oFacility = new Facility();
> this.GetFacilitiesByCustomerId(this.ClientCode);
> this.BindingSource = "Facility";
> this.BindingSourceDisplayMember = "Descr";
> this.BindingSourceValueMember = "Fac_Num";
> }
>}
>
>Regards,
Thanks
Jim