473,396 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

ObjectDataSource Update Exception Handling

Hi,

Given an ObjectDataSource and GridView declared as:

<asp:ObjectDataSource runat="server" ID="FullCategoryList"
TypeName="AD.App_Code.CategoryDataMapper"
SelectMethod="GetCategories" SortParameterName="SortExpression"
DataObjectTypeName="AD.App_Code.Category"
UpdateMethod="UpdateCategory"></asp:ObjectDataSource>

<asp:GridView ID="Categories" runat="server"
DataSourceID="FullCategoryList" AutoGenerateColumns="False"
AllowPaging="True" AllowSorting="True"
EnableSortingAndPagingCallbacks="False"
EnableViewState="False">
<Columns>
<asp:BoundField DataField="CategoryID" HeaderText="CategoryID"
SortExpression="CategoryID" />
<asp:BoundField DataField="CategoryName"
HeaderText="CategoryName" SortExpression="CategoryName" />
<asp:BoundField DataField="Description" HeaderText="Description"
SortExpression="Description" />
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>

I have a method in CategoryDataMapper called UpdateCategory, the method call
works correctly, what I'd like to know is if UpdateCategory throws an
exception where can I catch it to display an error to the user as to why the
details were not updated.
TIA

MattC
Apr 25 '07 #1
1 2958
Have you tried handling the ObjectDataSource.OnUpdated event? I believe
there is a property in the event arguments called Exception.

"MattC" <m@m.comwrote in message
news:eY*************@TK2MSFTNGP05.phx.gbl...
Hi,

Given an ObjectDataSource and GridView declared as:

<asp:ObjectDataSource runat="server" ID="FullCategoryList"
TypeName="AD.App_Code.CategoryDataMapper"
SelectMethod="GetCategories" SortParameterName="SortExpression"
DataObjectTypeName="AD.App_Code.Category"
UpdateMethod="UpdateCategory"></asp:ObjectDataSource>

<asp:GridView ID="Categories" runat="server"
DataSourceID="FullCategoryList" AutoGenerateColumns="False"
AllowPaging="True" AllowSorting="True"
EnableSortingAndPagingCallbacks="False"
EnableViewState="False">
<Columns>
<asp:BoundField DataField="CategoryID" HeaderText="CategoryID"
SortExpression="CategoryID" />
<asp:BoundField DataField="CategoryName"
HeaderText="CategoryName" SortExpression="CategoryName" />
<asp:BoundField DataField="Description"
HeaderText="Description" SortExpression="Description" />
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>

I have a method in CategoryDataMapper called UpdateCategory, the method
call works correctly, what I'd like to know is if UpdateCategory throws an
exception where can I catch it to display an error to the user as to why
the details were not updated.
TIA

MattC
Apr 25 '07 #2

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

Similar topics

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...
12
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press...
5
by: Ole M | last post by:
I'm having some trouble using the ObjectDataSource in ASP.NET 2.0. I have a wrapper that contains the static methods for Select and Update. The Update-method takes the business object as...
0
by: Richard Carpenter | last post by:
I am working on a small project in which I am trying to implement a data access layer through the use of a project dataset schema. Data integrity and normalization will be handled through the use...
2
by: Manjunath | last post by:
HI, How to catch custom exception using ObjectDataSource Control. I am calling Business Layer method through ObjectDataSource control, when Business layer method throws exception which will be...
2
by: Kevin Frey | last post by:
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...
1
by: Pao | last post by:
I have a formview bounded to an objectdatasource. All ok but I have some trouble with a checkbox: when I am in update mode and I update the record, this field is never updated (no errors thrown)....
1
by: =?Utf-8?B?cm9zczYxMw==?= | last post by:
I really hope this is not a case of "this silly thing will never work".....lots of time invested in troubleshooting this already. I have created a standard ASP.NET web form (.aspx) with several...
0
by: steve | last post by:
I have been fighting with trying to update a GridView for a while. I don't want to use the "built-in" way to do it because I am using business layer methods for updating and deleteing and I don't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.