ObjectDataSource Update Exception Handling

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MattC

    #1

    ObjectDataSource 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


  • Ryan Westphal

    #2
    Re: ObjectDataSourc e Update Exception Handling

    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:eYI3YLyhHH A.208@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
    >

    Comment

    Working...