how to use SetColumnError in business Object CSLA???

how to use SetColumnError in business Object CSLA???

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


GoldenB posted on Monday, September 03, 2007

Halo..im newbie. I have problem to use SetColumnError in business object. Can anyone give me a solution. Because this is very urgent...thks

Vinodonly replied on Tuesday, September 04, 2007

Pls check the PTracker example for more details.

In your business object

protected override void AddBusinessRules()

{

// Add your req validations - here as an example we want to verify "Name" column with a method called ValueRequired.

ValidationRules.AddRule(CommonRules.ValueRequired, "Name");

}

 

In the ValueRequired method which will define in this way:

static public bool ValueRequired(object target, Csla.Validation.RuleArgs e)

{

// Do checks here, if result is false then

if (!Result)

{

e.Description = String.Format("Value Cannot be Blank", e.PropertyName);

return false;

}

 

}

This will set the error message for that column. I hope have understood your question properly.

GoldenB replied on Tuesday, September 04, 2007

ok..i will try it..thks

GoldenB replied on Tuesday, September 04, 2007

Vinodonly:

Pls check the PTracker example for more details.

In your business object

protected override void AddBusinessRules()

{

// Add your req validations - here as an example we want to verify "Name" column with a method called ValueRequired.

ValidationRules.AddRule(CommonRules.ValueRequired, "Name");

}

 

In the ValueRequired method which will define in this way:

static public bool ValueRequired(object target, Csla.Validation.RuleArgs e)

{

// Do checks here, if result is false then

if (!Result)

{

e.Description = String.Format("Value Cannot be Blank", e.PropertyName);

return false;

}

 

}

This will set the error message for that column. I hope have understood your question properly.


i allready try it, and how to use ValidationRules in ReadOnlyBase<T>???

actualy my problem is i want use setcolumerror in a grid,can u give me a solution??

Copyright (c) Marimer LLC