473,785 Members | 2,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ObjectDataSourc e Update Exception Handling

Hi,

Given an ObjectDataSourc e and GridView declared as:

<asp:ObjectData Source runat="server" ID="FullCategor yList"
TypeName="AD.Ap p_Code.Category DataMapper"
SelectMethod="G etCategories" SortParameterNa me="SortExpress ion"
DataObjectTypeN ame="AD.App_Cod e.Category"
UpdateMethod="U pdateCategory"> </asp:ObjectDataS ource>

<asp:GridView ID="Categories " runat="server"
DataSourceID="F ullCategoryList " AutoGenerateCol umns="False"
AllowPaging="Tr ue" AllowSorting="T rue"
EnableSortingAn dPagingCallback s="False"
EnableViewState ="False">
<Columns>
<asp:BoundFie ld DataField="Cate goryID" HeaderText="Cat egoryID"
SortExpression= "CategoryID " />
<asp:BoundFie ld DataField="Cate goryName"
HeaderText="Cat egoryName" SortExpression= "CategoryNa me" />
<asp:BoundFie ld DataField="Desc ription" HeaderText="Des cription"
SortExpression= "Descriptio n" />
<asp:CommandFie ld ShowEditButton= "True" />
</Columns>
</asp:GridView>

I have a method in CategoryDataMap per 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 2981
Have you tried handling the ObjectDataSourc e.OnUpdated event? I believe
there is a property in the event arguments called Exception.

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

Given an ObjectDataSourc e and GridView declared as:

<asp:ObjectData Source runat="server" ID="FullCategor yList"
TypeName="AD.Ap p_Code.Category DataMapper"
SelectMethod="G etCategories" SortParameterNa me="SortExpress ion"
DataObjectTypeN ame="AD.App_Cod e.Category"
UpdateMethod="U pdateCategory"> </asp:ObjectDataS ource>

<asp:GridView ID="Categories " runat="server"
DataSourceID="F ullCategoryList " AutoGenerateCol umns="False"
AllowPaging="Tr ue" AllowSorting="T rue"
EnableSortingAn dPagingCallback s="False"
EnableViewState ="False">
<Columns>
<asp:BoundFie ld DataField="Cate goryID" HeaderText="Cat egoryID"
SortExpression= "CategoryID " />
<asp:BoundFie ld DataField="Cate goryName"
HeaderText="Cat egoryName" SortExpression= "CategoryNa me" />
<asp:BoundFie ld DataField="Desc ription"
HeaderText="Des cription" SortExpression= "Descriptio n" />
<asp:CommandFie ld ShowEditButton= "True" />
</Columns>
</asp:GridView>

I have a method in CategoryDataMap per 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
5655
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 using an object that calls a web service to accomplish this. The service returns a message to the Insert method that indicates that the insert can't be accomplished because it is trying to insert a duplicate key value. So, I simply want to raise...
12
8706
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 update after making changes, but I don't want that update button. How can I get the updated object when the user presses one of my other action buttons?
5
1990
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 parameter. When the Update-method is invoked by the ObjectDataSource, the object referenced is not the same object returned by the Select-method, but a new object with only the values from the Edit-template. So basically I get a reference to a useless...
0
1163
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 of SQL Server stored procedures. Basically, for each data entity, I've written _Get(), _Delete(), _Add() and _Update() stored procedures. The _Get() procs return all data needed to display the information in a meaningful manner to the user...
2
2976
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 wrapped to custom exception and thrown. I want to capture the custom exception in UI Layer. e.g., UI Layer Code: protected void Page_Load(object sender, EventArgs e)
2
1773
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 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...
1
6569
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). The field bounded in the database (MySql) is a string field (ENUM('True','False') default 'False'. The checkbox is correctly bounded in the itemtemplate and in the edititemtemplate.
1
1706
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 collections of textboxes prompting for entry into a fairly monolithic database. I decided to create a business object (called Employee) and use the ObjectDataSource to broker data being transmitted between the UI and my Employee object (and...
0
4282
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 want to have my parameter names in those methods have to be "original_Parametername" or even if I change the OldValuesParameterFormatString to get rid of the "original" I would still have just "Parametername". I think most people user parameters...
0
10325
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.