Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Server validating a new row (addNewRow template)
posted

Hello,

I'm looking for a way to perform server (business rule) validation of a new row that is added with the addNewRow template of a WebDataGrid.

Right now i use the following structure: WebDataGrid --> ObjectDataSource --> BusinessClass --> DataAccess. I'm doing the business validation in de businessclass. something like this:

        [DataObjectMethod(DataObjectMethodType.Update)]
        public static Entitity Update(Entitity c)
        {
            ValidationResults results = Validation.ValidateFromConfiguration<Entitity>(c);
            if (results.IsValid)
            {
                Repository.Update(c);
            }
            else
            {
                throw new ValidationException(results);
            }

            return c;
        }

I dont really like this, but it works because the objectdatasource has an Updated event that automaticly catches all the exceptions and allows you to handle them.

The problem is with inserting rows. I do the same thing there but how can I tell the grid that the row to insert was not valid and was not inserted yet? The row needs to stay in the 'addNewRow' row at the bottom of the grid, but I cant get it working.

I need to do this validation on the serverside, and i'm wondering if there is something i'm missing here, because it sounds pretty basis, but turns out to be very difficult..

 

Parents
No Data
Reply Children
No Data