ErrorProvider/Combobox -- validation not showing

ErrorProvider/Combobox -- validation not showing

Old forum URL: forums.lhotka.net/forums/t/973.aspx


hmadanaraj posted on Monday, August 21, 2006

I am fairly new to CSLA so I might be doing something silly. Your help/guidance is very much appreicated.

Situation: I have 3 comboboxes on the form (style is set to: dropdownlist) and 1 errorProvider control.

Sample Data:  (a) "Select One", "Blue", "Red", "Green"

(b) "Select One", "Large", "Medium", "Small"

(c) "Select One", "John", "Susie", "Cathy"

Problem: When the form first loads up it renders with "Select One" selection, but the icon of the "ErrorProvider" control is not shown. When I cause the slection changed event by Re-selecting the "Select One" choice, the icon of the "ErrorProvider" control starts blinking....This not a problem for the other string or date control on the form which are also the required fields.

Question: What should I do to make the icon of the error-provider show on form load (without, I having to cause the "selection changed")

Thank you

Hari

RockfordLhotka replied on Wednesday, August 23, 2006

Make sure your data binding is set up correctly. The error provider control will work fine with a combobox control, but only if the control is properly configured with data binding.

I usually use drag-and-drop binding to get it set up right ( because otherwise I almost always bind the wrong control properties...)

  1. get rid of any existing control on your form
  2. in the Data Sources window, configure the object's property to use a combobox
  3. drag the property onto the form to create the combobox
  4. now drag the list object containing the list items from Data Sources onto the combobox
I have found this to be a reliable way to get combobox binding to work.

hmadanaraj replied on Wednesday, August 23, 2006

Thank you for your reply Rocky…

That helped – that’s a cool way to bind.

 

But, now I am stuck at another hurdle (lack of CSLA knowledge. Trying to learn CSLA, while trying to keep up with the project time-line)

 

Your help is very much appreciated.

 

Table structure is as follows: ‘Project’ table has a foreignKey (fkFacilityInfo), pointing to ‘FacilityInfo’ table.

I have two objects ‘Project’ and ‘FacilityInfo’ Project object has reference to the FaclityInfo object through the variable (_facilityInfo).

 

If I update a property on the ‘Project’ object and press the save button, both the parent (Project) and the child (FacilityInfo) gets updated – No problem.

 

How do I call the update on the child object (FacilityInfo) when I just update a property on the facilityInfo object without updating the property on the parent object (Project).

 

Along the same lines of problem (Parent/Chile), how do I call the ‘ValidationRules.CheckRules(); on the child ?

 

 

Code Sample on the Project.cs:

***********************

private void DataPortal_Create(Criteria criteria)

{                

/// Initialize all the related child objects

      _facilityInfo = FacilityInfo.GetNew();

                 

      InitializeProperty();

 

      ValidationRules.CheckRules();

}

 

protected override void DataPortal_Update()

{                

      ///tried the below two lines, hoping that it would call DataPortal_Update on the FacilityInfo   ///object – but did not work

//_facilityInfo.ApplyEdit();

//_facilityInfo.Save();

 

_facilityInfo.Update();

      Update();

}

 

private void Update()

{

    ProjectConfigurationDAL.SetProject(this);

}

 

Code Sample on the FacilityInfo.cs

**********************************

   public static FacilityInfo GetNew()

   {           

      return new FacilityInfo();

   }

 

private FacilityInfo()

{          

   _state = "-1";

   //ValidationRules.CheckRules(); ///commented this line as it was breaking

}

 

internal void Update()

        {

            ProjectConfigurationDAL.SetFacilityInfo(this);

        }

 

 

      /// The below method never gets executed

        protected override void DataPortal_Update()

        {

            Update();

        }

 

Thanks a ton in advance !!!

 

Regards

Hari


From: RockfordLhotka [mailto:cslanet@lhotka.net]
Sent: Wednesday, August 23, 2006 8:09 AM
To: Hari Madanaraj
Subject: Re: [CSLA .NET] ErrorProvider/Combobox -- validation not showing

 

Make sure your data binding is set up correctly. The error provider control will work fine with a combobox control, but only if the control is properly configured with data binding.

I usually use drag-and-drop binding to get it set up right ( because otherwise I almost always bind the wrong control properties...)

  1. get rid of any existing control on your form
  2. in the Data Sources window, configure the object's property to use a combobox
  3. drag the property onto the form to create the combobox
  4. now drag the list object containing the list items from Data Sources onto the combobox

I have found this to be a reliable way to get combobox binding to work.



Copyright (c) Marimer LLC