SetEntityFieldError => Clear

Posts   
 
    
ianvink
User
Posts: 394
Joined: 15-Dec-2006
# Posted on: 16-Oct-2008 17:54:50   

I use SetEntityFieldError in the OnValidateFieldValue() nicely.

When the user fixes the data, the OnValidateFieldValue doesn't fire.

What should I override to clear the IDataError...and how do I clear that so it bubbles up to the UI?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 17-Oct-2008 05:09:12   

When the user fix the value, he back to the original value? Is your GUI ASP.Net or WinForms?

Also, post the code you have on the OnValidateFieldValue() method.

David Elizondo | LLBLGen Support Team
ianvink
User
Posts: 394
Joined: 15-Dec-2006
# Posted on: 17-Oct-2008 13:29:34   

Hi,

It's WinForms.

When the user corrects the data, it does not clear.

This is a Hello-World kind of app. Simple POC.



        protected override bool OnValidateFieldValue(int fieldIndex, object value)
        {
            bool toReturn = true;
            switch ((CustomerFieldIndex)fieldIndex)
            {
                case CustomerFieldIndex.Country:
                    if (value.ToString() != "USA" && this.User != null && this.User.Country == "USA")
                    {
                        SetEntityFieldError(CustomerFields.Country.Name, "USA users can only set country to USA", true);
                        toReturn = false;
                    }
                    break;
                default:
                    toReturn = true;
                    break;
            }
            return toReturn;
        }


daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 17-Oct-2008 14:06:50   

You have to clean it if the validation passes...:

        protected override bool OnValidateFieldValue(int fieldIndex, object value)
        {
            bool toReturn = true;
            switch ((CustomerFieldIndex)fieldIndex)
            {
                case CustomerFieldIndex.Country:
                    if (value.ToString() != "USA" && this.User != null && this.User.Country == "USA")
                    {
                        SetEntityFieldError(CustomerFields.Country.Name, "USA users can only set country to USA", true);
                        toReturn = false;
                    }
                    else
                    {
                          SetEntityFieldError(CustomerFields.Country.Name, string.Empty, false);
                    }
                    break;
                default:
                    toReturn = true;
                    break;
            }
            return toReturn;
        }
David Elizondo | LLBLGen Support Team