Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > ObjectDataSource and GridView - Handling Errors During DataBinding

Reply
Thread Tools

ObjectDataSource and GridView - Handling Errors During DataBinding

 
 
Mythran
Guest
Posts: n/a
 
      08-06-2009
We have a class that contains the Fetch/Insert/Update/Delete methods that a
DataObjectSource uses to fetch/insert/update/delete for a GridView control.
The Fetch method accepts a single parameter which is a custom class used for
building a search that is then transformed into SQL based on user-input.

Inside the class containing the Fetch/etc. methods, the Fetch method may
throw an exception because the user didn't enter anything in a search/fetch.
The exception is a custom validation exception that notifies the user that
they are required to enter at least one criteria field in order to perform
the search. Is there an event, method, etc. that I can use on either the
ObjectDataSource or GridView control classes to handle the error and display
a message to the user instead of the page redirecting to the unhandled
exception page?

Thanks,
Mythran


 
Reply With Quote
 
 
 
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      08-07-2009
Hi Mythran,

>Is there an event, method, etc. that I can use on either the
>ObjectDataSource or GridView control classes to handle the error and

display
>a message to the user instead of the page redirecting to the unhandled
>exception page?


You can handle the exception in the Selected event handler of
ObjectDataSource. Like below:

protected void ObjectDataSource1_Selected(object sender,
ObjectDataSourceStatusEventArgs e)
{
if (e.Exception != null) {
//handle exception
e.ExceptionHandled = true;
}
}

Please let me know if it works and feel free to ask if you have additional
questions.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the

support we provide to you. Please feel free to let my manager know what you
think of the level of service provided.

You can send feedback directly to my manager at: .

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-

us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community

or a Microsoft Support Engineer within 2 business day is acceptable. Please
note that each follow up response may

take approximately 2 business days as the support professional working with
you may need further investigation to

reach the most efficient resolution. The offering is not appropriate for
situations that require urgent, real-time

or phone-based interactions. Issues of this nature are best handled working
with a dedicated Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-

us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
 
Mythran
Guest
Posts: n/a
 
      08-11-2009

"Allen Chen [MSFT]" <> wrote in message
news:...
> Hi Mythran,
>
>>Is there an event, method, etc. that I can use on either the
>>ObjectDataSource or GridView control classes to handle the error and

> display
>>a message to the user instead of the page redirecting to the unhandled
>>exception page?

>
> You can handle the exception in the Selected event handler of
> ObjectDataSource. Like below:
>
> protected void ObjectDataSource1_Selected(object sender,
> ObjectDataSourceStatusEventArgs e)
> {
> if (e.Exception != null) {
> //handle exception
> e.ExceptionHandled = true;
> }
> }
>
> Please let me know if it works and feel free to ask if you have additional
> questions.
>
> Regards,
> Allen Chen
> Microsoft Online Support
>
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the
>
> support we provide to you. Please feel free to let my manager know what
> you
> think of the level of service provided.
>
> You can send feedback directly to my manager at: .
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/en-
>
> us/subscriptions/aa948868.aspx#notifications.
>
> Note: MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community
>
> or a Microsoft Support Engineer within 2 business day is acceptable.
> Please
> note that each follow up response may
>
> take approximately 2 business days as the support professional working
> with
> you may need further investigation to
>
> reach the most efficient resolution. The offering is not appropriate for
> situations that require urgent, real-time
>
> or phone-based interactions. Issues of this nature are best handled
> working
> with a dedicated Microsoft Support
>
> Engineer by contacting Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/en-
>
> us/subscriptions/aa948874.aspx
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>


I believe this is what I was looking for. Thank you.

Mythran


 
Reply With Quote
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      08-12-2009
>I believe this is what I was looking for. Thank you.

>Mythran


You're welcome! Thank you for using our Newsgroup Support Service!

Regards,
Allen Chen
Microsoft Online Community Support



=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.
=================================================

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent ObjectDataSource/GridView from DataBinding richardl@conceptsearching.com ASP .Net 1 04-18-2007 06:08 PM
ObjectDataSource with Complex Objects and 2 way Databinding =?Utf-8?B?VHJhaWwgTW9uc3Rlcg==?= ASP .Net 5 01-12-2007 10:53 PM
Gridview encoding, or how to run commands before gridview's default databinding, or, how do I disable default databinding at all? Sergei Shelukhin ASP .Net 1 11-12-2006 01:43 PM
Handling Errors wrt ObjectDataSource Kevin Frey ASP .Net 2 11-08-2006 10:29 PM
Cell handling when databinding in a GridView HEM ASP .Net Datagrid Control 0 08-23-2005 01:33 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57