472,958 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Handling Errors wrt ObjectDataSource

One of my chief criticisms of validators in an ASP.NET page is that they can
result in a developer re-implementing much of the "business logic" of a
transaction at the page level.

Assuming we have an object that implements business logic, and that object
is utilised via an ObjectDataSource, I wish to enquire what the correct
method is for handling errors from the business logic object.

For example, there are some circumstances where a transaction cannot be
completed due to a validation error. But for the sake of this discussion,
and to remove any potential for using a "Validator" in a pre-validation
sense, let's assume the "validation error" is due to a
transaction-time-determined consistency-related operation such as an
organisation exceeding their credit limit at the time of placing an order.
Clearly in a multi-user system such a test can only be performed when the
operation is being committed to the database, because otherwise it is
[potentially] subject to violation.

So, with a view to "best practices implementation", how should my business
logic object report such an error? Throw an exception?

And how should my page react to such an exception? Should I be hooking event
handlers onto the Inserted, Deleted (etc) events of ObjectDataSource and
then interrogating the ObjectDataSourceStatusEventArgs object for the
presence of an Exception?

If there is an exception, what would a typical course of action be? Would it
be feasible to somehow inject a message into a ValidationSummary control?

Many thanks

Kevin

Nov 7 '06 #1
2 1726
If I understand your rather wordy hypothesis, it seems you are questioning
whether it is feasible to propagate a business - logic failed transaction
condition up to the UI where page-level validation is being used.

I guess it really boils down to whether or not the page-level field
validators are really concerned with a business - logic condition, and
normally, they are not.

So what I'd be looking at is simply an elegant way to inform the user that
although there was nothing wrong with their inputs, the transaction failed
and show them the reason if appropriate. How you do this is of course
entirely up to you to determine. A simple message on a label should suffice.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Kevin Frey" wrote:
One of my chief criticisms of validators in an ASP.NET page is that they can
result in a developer re-implementing much of the "business logic" of a
transaction at the page level.

Assuming we have an object that implements business logic, and that object
is utilised via an ObjectDataSource, I wish to enquire what the correct
method is for handling errors from the business logic object.

For example, there are some circumstances where a transaction cannot be
completed due to a validation error. But for the sake of this discussion,
and to remove any potential for using a "Validator" in a pre-validation
sense, let's assume the "validation error" is due to a
transaction-time-determined consistency-related operation such as an
organisation exceeding their credit limit at the time of placing an order.
Clearly in a multi-user system such a test can only be performed when the
operation is being committed to the database, because otherwise it is
[potentially] subject to violation.

So, with a view to "best practices implementation", how should my business
logic object report such an error? Throw an exception?

And how should my page react to such an exception? Should I be hooking event
handlers onto the Inserted, Deleted (etc) events of ObjectDataSource and
then interrogating the ObjectDataSourceStatusEventArgs object for the
presence of an Exception?

If there is an exception, what would a typical course of action be? Would it
be feasible to somehow inject a message into a ValidationSummary control?

Many thanks

Kevin

Nov 8 '06 #2
Forgive me for my wordiness. I wanted to make sure someone didn't try
subvert the problem by simply "suggesting" I use a validator - when clearly
a validator cannot be used in some circumstances.

As an aside, I don't necessarily agree with your assertion that page-level
field validators are not really concerned with "business logic", except
those validators that are concerned merely with "domain-specific" type
validation (eg. ensuring a date is formatted correctly or something).
Everything else starts to become associated with the "contractual
requirements" of the business logic interface (eg. value X must be between 1
and 10, etc), and viewed in this manner it is entirely possible to implement
a large number of validators under the guise of meeting the contractual
requirements of the interface (ie. to ensure that I give it the right inputs
so it doesn't blow up).
So what I'd be looking at is simply an elegant way to inform the user that
although there was nothing wrong with their inputs, the transaction failed
and show them the reason if appropriate. How you do this is of course
entirely up to you to determine. A simple message on a label should
suffice.
Unfortunately, you've simply reiterated my question and told me to solve it
myself. Hence your answer is really no answer at all (and I say that without
malice, because I appreciate you replying nonetheless). Yes, I understand I
could use a label to issue an error message. I'm looking for "best
practices" methodologies for handling these sorts of problems. Are you
suggesting this is good as it is going to get?

Kevin

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:D8**********************************@microsof t.com...
If I understand your rather wordy hypothesis, it seems you are questioning
whether it is feasible to propagate a business - logic failed transaction
condition up to the UI where page-level validation is being used.

I guess it really boils down to whether or not the page-level field
validators are really concerned with a business - logic condition, and
normally, they are not.

So what I'd be looking at is simply an elegant way to inform the user that
although there was nothing wrong with their inputs, the transaction failed
and show them the reason if appropriate. How you do this is of course
entirely up to you to determine. A simple message on a label should
suffice.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Kevin Frey" wrote:
>One of my chief criticisms of validators in an ASP.NET page is that they
can
result in a developer re-implementing much of the "business logic" of a
transaction at the page level.

Assuming we have an object that implements business logic, and that
object
is utilised via an ObjectDataSource, I wish to enquire what the correct
method is for handling errors from the business logic object.

For example, there are some circumstances where a transaction cannot be
completed due to a validation error. But for the sake of this discussion,
and to remove any potential for using a "Validator" in a pre-validation
sense, let's assume the "validation error" is due to a
transaction-time-determined consistency-related operation such as an
organisation exceeding their credit limit at the time of placing an
order.
Clearly in a multi-user system such a test can only be performed when the
operation is being committed to the database, because otherwise it is
[potentially] subject to violation.

So, with a view to "best practices implementation", how should my
business
logic object report such an error? Throw an exception?

And how should my page react to such an exception? Should I be hooking
event
handlers onto the Inserted, Deleted (etc) events of ObjectDataSource and
then interrogating the ObjectDataSourceStatusEventArgs object for the
presence of an Exception?

If there is an exception, what would a typical course of action be? Would
it
be feasible to somehow inject a message into a ValidationSummary control?

Many thanks

Kevin


Nov 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Christian Christmann | last post by:
Hi, assert and error handling can be used for similar purposes. When should one use assert instead of try/catch and in which cases the error handling is preferable? I've read somewhere that...
2
by: nunya5200-bidness | last post by:
I hope someone may have some insight to this issue... I would like to know how to properly implement exception handling using the ObjectDataSource control. Specfically, I am doing an insert...
2
by: J055 | last post by:
Hi I've implemented caching for my ObjectDataSource. <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" EnableCaching="True" CacheDuration="10" CacheExpirationPolicy="Sliding" ...
5
by: Dabbler | last post by:
What is the best way to handle data interpolation between form controls and the actual sql data field. I have radio buttons that need to be interpreted, form values that have to be translated.....
3
by: Howard | last post by:
I use FormView and ObjectDataSource to take user inputs in adduser.aspx page i have <asp:ObjectDataSource ID="ds1" runat="server" TypeName="datapage" InsertMethod="addstudent"> and in my...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
0
by: acnx | last post by:
I have an ntier application. I am trying to determine what is the best practice for handing errors in a datagrid. My datagrids are able to add, update and delete data. I am using a...
1
by: MattC | last post by:
Hi, Given an ObjectDataSource and GridView declared as: <asp:ObjectDataSource runat="server" ID="FullCategoryList" TypeName="AD.App_Code.CategoryDataMapper" SelectMethod="GetCategories"...
2
by: Omar Abid | last post by:
Reason of this project: Error handling is one of the most difficult thing that may afford a programmer. It isn't as easy as you think and handling errors in a program some time can make errors...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.