Update Master GridView with updates in Details View

Discussion in 'ASP .Net Datagrid Control' started by Jeronimo Bertran, May 30, 2006.

  1. Hello,

    I have create a master/detail using a GridView and a FormView. My
    DataSource for the detailed FormView is linked to the GridView by the
    details ObjectDataSource whiche looks like the following:

    <asp:ObjectDataSource ID="ObjectDataSourceEventDetails"
    runat="server" SelectMethod="SelectEventDetails" TypeName="EventData"
    UpdateMethod="UpdateEventDetails">
    <SelectParameters>
    <asp:ControlParameter ControlID="GridViewEvents" Name="eventID"
    PropertyName="SelectedValue" Type="Int64" />
    </SelectParameters>
    </asp:ObjectDataSource>



    When I update the record on the FormView by ussing the FormView.UpdateItem,
    the modified item is shown on the form view but the changes are not
    reflected on the master GridView. Is there some way to do this?

    Thanks,

    Jeronimo Bertran
     
    Jeronimo Bertran, May 30, 2006
    #1
    1. Advertising

  2. Hi Jeronimo,

    Thank you for your post!

    Are the GridView and FormView binding to the same DataSource object?

    Normally data-bound controls automatically re-bind to their data source
    whenever the data source changes (for example after an update). However, if
    the GridView is bound to a different data source than the FormView, so when
    the Update operation is invoked, only the FormView receives a change event
    from its data source. To force the GridView to also re-bind when the
    FormView performs an update, you can call DataBind() explicitly on GridView
    in the FormView ItemUpdated event.

    Hope this helps. If anything is unclear, please feel free to post here.


    Regards,
    Walter Wang
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Walter Wang [MSFT], May 31, 2006
    #2
    1. Advertising

  3. Thanks Walter,

    I do have separate DataSources and the DatBind on the ItemUpdated event
    worked.

    However, I have a question, you mentioned using the same DataSource for
    both Master and Detail but I don't undestand how to do this. Currently I
    have two DataSources and for the details datasource I define a
    SelectParameter that is bound to the Master GridView SelectedValue event.



    <SelectParameters>
    <asp:ControlParameter ControlID="GridViewEvents" Name="eventID"
    PropertyName="SelectedValue" Type="Int64" />
    </SelectParameters>


    How can I achieve the master/detail with the same DataSource?

    Thanks,

    Jeronimo Bertran
     
    Jeronimo Bertran, Jun 1, 2006
    #3
  4. Hello,

    I think Walter means if they controls are bound to same underlying
    datasourece (database, maybe), so that the data on the page can be
    refreshed correctly. If it is ASP.NET ObjectDataSource component, I think
    we need to use two different ObjectDataSource components on Master and
    Detail pages, your solution is just on the way.

    If there is any further question, please feel free to let us know.

    Thanks,

    Luke Zhang
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Luke Zhang [MSFT], Jun 2, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page