W
windsurfing_stew
Hi Group,
I've put business logic into my typed datasets, eg:
protected override void
OnColumnChanging(System.Data.DataColumnChangeEventArgs e)
{
// Ensure price valid
if (e.Column == this.PriceColumn)
{
if ((decimal)e.ProposedValue < 0)
e.Row.SetColumnError(e.Column, "Please ensure
that the price greater than zero");
else
e.Row.SetColumnError(e.Column, "");
}
...
base.OnColumnChanging(e);
}
}
In my windows form I've bound this typed dataset to a BindingSource,
then bound fields to that. All words well. I've also bound an
ErrorProvider to this BindingSource. I
I have two problems -
1) I can still save a record even if the red icon is shown.
2) If the focus never enters and hence never leaves the bound textbox
then this validation is never called and the user never knows.
Any ideas on how to get around this? I'm surprised MS haven't come up
with an easy solution to allow business logic to be stored in the typed
dataset and enforced reliably on at the windows forms level. Thoughts?
Stewart
I've put business logic into my typed datasets, eg:
protected override void
OnColumnChanging(System.Data.DataColumnChangeEventArgs e)
{
// Ensure price valid
if (e.Column == this.PriceColumn)
{
if ((decimal)e.ProposedValue < 0)
e.Row.SetColumnError(e.Column, "Please ensure
that the price greater than zero");
else
e.Row.SetColumnError(e.Column, "");
}
...
base.OnColumnChanging(e);
}
}
In my windows form I've bound this typed dataset to a BindingSource,
then bound fields to that. All words well. I've also bound an
ErrorProvider to this BindingSource. I
I have two problems -
1) I can still save a record even if the red icon is shown.
2) If the focus never enters and hence never leaves the bound textbox
then this validation is never called and the user never knows.
Any ideas on how to get around this? I'm surprised MS haven't come up
with an easy solution to allow business logic to be stored in the typed
dataset and enforced reliably on at the windows forms level. Thoughts?
Stewart