473,769 Members | 6,583 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 2980
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
8705
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
4281
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
9424
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10051
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8879
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
7413
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
6675
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
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
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
2815
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.