Update Master GridView with updates in Details View

J

Jeronimo Bertran

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
 
W

Walter Wang [MSFT]

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.
 
J

Jeronimo Bertran

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
 
L

Luke Zhang [MSFT]

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.)
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top