Question

I'm using DataForm with a ria domain services which uses a table called country. As the dataform doesn't automaticly adds a new country to the table after clicking Ok I've written code doing it in the EditEnding Event of the DataForm.

But why comes the validation of the user input after the EditEnding event?

If I add a new country without a name it should push up a validation error before entering EditEnding but at this time there are no validation errors. After the Event is fired I'm getting the validation error.

How can I use the automatic validation to make my code working?

private void CountryDataForm_EditEnding(object sender, DataFormEditEndingEventArgs e)
    {
        if (e.EditAction == DataFormEditAction.Commit)
        {
            if (CountryDataForm.Mode == DataFormMode.AddNew)
            {
                if (!CountryDataForm.ValidationSummary.HasErrors)
                {
                    Country item = CountryDataForm.CurrentItem as Country;
                    item.CountryID = Guid.NewGuid();
                    GridData.SubmitChanges();
                }
            }
        }
    }
Was it helpful?

Solution

Ok, I found the solution. I tried to commit changes in the EditEnding-Event. This should happen in the EditEnded-Event of the DataForm.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top