J
JimLad
Hi,
ASP.NET 3.5
I've recently been struggling with BLL Validation and when and where I
should do it.
I have a Gridview using an ObjectDataSource. This is a standard thing
that I'll be doing on loads of pages and I will be creating a
template
for this.
Obviously I can validate in the Gridview_Updating event. However,
nothing is typed at this point so I would have to type everything
manually. Values are typed in ObjectDataSource_Updating, but by then
I've lost the e.cancel function and would have to raise an exception
to cancel.
Returning to Gridview_Updating I can pass the typed values I need
individually or I can pass the IOrderDictionary of values, newvalues
or keys. However these are untyped and I would have to them type them
in the BLL layer so I've rejected this option.
Or I can Validate in the BLL layer in the Update function (called by
UpdateMethod of the ObjectDataSource). I have a Generic List of
validation failures to return and I also want to keep
the entered values on the page, not refresh the page if there are
validation problems. The only way to prevent the page from refreshing
seems to be to return an exception to GridView_Updated. I could
create
a new Exception which contains the Validation Error Generic List. But
I have always thought that Exceptions should not be raised for
standard functionality like this?
Basically I want to limit bespoke validation functionality to the BLL
layer and not have to do manual typing on the UI layer. But I can't
seem to find a way of doing that without raising exceptions.
Any advice would be very welcome. If these are the only 2 options,
which should I do? I realise it would take very little effort to type
values manually on the UI side for each page, but I always like to
standardise code where possible.
James
ASP.NET 3.5
I've recently been struggling with BLL Validation and when and where I
should do it.
I have a Gridview using an ObjectDataSource. This is a standard thing
that I'll be doing on loads of pages and I will be creating a
template
for this.
Obviously I can validate in the Gridview_Updating event. However,
nothing is typed at this point so I would have to type everything
manually. Values are typed in ObjectDataSource_Updating, but by then
I've lost the e.cancel function and would have to raise an exception
to cancel.
Returning to Gridview_Updating I can pass the typed values I need
individually or I can pass the IOrderDictionary of values, newvalues
or keys. However these are untyped and I would have to them type them
in the BLL layer so I've rejected this option.
Or I can Validate in the BLL layer in the Update function (called by
UpdateMethod of the ObjectDataSource). I have a Generic List of
validation failures to return and I also want to keep
the entered values on the page, not refresh the page if there are
validation problems. The only way to prevent the page from refreshing
seems to be to return an exception to GridView_Updated. I could
create
a new Exception which contains the Validation Error Generic List. But
I have always thought that Exceptions should not be raised for
standard functionality like this?
Basically I want to limit bespoke validation functionality to the BLL
layer and not have to do manual typing on the UI layer. But I can't
seem to find a way of doing that without raising exceptions.
Any advice would be very welcome. If these are the only 2 options,
which should I do? I realise it would take very little effort to type
values manually on the UI side for each page, but I always like to
standardise code where possible.
James