ObjectDataSource Update Exception Handling

M

MattC

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
 
R

Ryan Westphal

Have you tried handling the ObjectDataSource.OnUpdated event? I believe
there is a property in the event arguments called Exception.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top