ObjectDataSource Update Exception Handling

  • Thread starter Thread starter MattC
  • Start date Start date
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
 
Have you tried handling the ObjectDataSource.OnUpdated event? I believe
there is a property in the event arguments called Exception.
 
Back
Top