ErrorProvider does not disappear after validation rule has been satisfied (combobox)

ErrorProvider does not disappear after validation rule has been satisfied (combobox)

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


Valentin_Vasiliev posted on Wednesday, December 17, 2008

I have a problem with ErrorProvider.

My BO has Enum field exposed as a property. Also it has a nullable integer property.
Enum is controlled by clicking the radio buttons in UI. This enum has only two values, and as a results two radio buttons in UI. The validation rule blindly returns true for first enum state and performs validation
logic in second state.
Problem:
I click the second radio button (check validation rule) - ErrorProvider starts blinking. Then I click other radio button (Validation rule returns true) - Error provider keeps on blinking, but the BO is now Valid.
Please hint what could be done to 'refill' the ErrorProvider with updated BO state.

Thank you.

Valentin.

Valentin_Vasiliev replied on Wednesday, December 17, 2008

Currently I'm getting around this by explicitly calling UpdateBinding method of ErrorProvider.
I would like the ErrorProvider to automatically update the icon when properties change.

Valentin.

whelzer replied on Wednesday, December 17, 2008

In VB 2005/2008 - check out the Advanced settings under (DataBindings) property, change Data Source Update Mode from OnValidation to OnPropertyChanged.

Valentin_Vasiliev replied on Wednesday, December 17, 2008

I had already tried this, it didn't help, unfortunately.

Thank you.

ajj3085 replied on Wednesday, December 17, 2008

Is a property changed event being raised for the property with the broken rule?

Valentin_Vasiliev replied on Wednesday, December 17, 2008

I think I will try to provide a bogus code to be more clear:
class Customer : BusinessBase<Customer>
{
//code for enum  as Csla property
private CustomerStatus _status;
public CustomerStatus Status
{
      //csla get;
      //csla set;
}

private int? _goldMemberRank;
public int? GoldMemberRank
{
     //csla get;
     //csla set;
}

//validation rules
ValidationRules.AddRule(CheckIfGoldMemberRankPresentOnlyIfStatusGold,"GoldMemberRank");

private static bool CheckIfGoldMemberRankPresentOnlyIfStatusGold(parameters here)
{
               if(target._status==CustomerStatus.Gold)
               {
                        if(_goldMemberRank.HasValue)
                                     return true;
                        else
                        {
                                e.Description="rank not set";
                                return false;
                         }
                }
                return true;
 }
}

public enum CustomeStatus
{
            Regular,
            GoldMember
}


This pseudo code shows my setup.

The enum is controlled by radio buttons in UI. When I click "gold member radio button" the validation rule is actually run. When I click "regular" the validation rule blindly returns 'true'.
 Problem:
When I click "gold" error provider starts blinking, when I immediately click 'regular' after then, it keeps blinking (but validation rule returns true and BO is valid).

Thank you.


Copyright (c) Marimer LLC