nested GridViews and server paging/sorting in ObjectContainerDataSource

Topics: Web Client Software Factory
Jan 17, 2007 at 9:59 AM

I have an inner GridView + ObjectContainerDataSource nested in the template of a TemplateField of an outer GridView. With server paging and sorting off on the nested inner ObjectContainerDataSource I can set its DataSource property in the RowDataBound event handler of the outer GridView using GridViewRowEventArgs.Row.DataItem to find the id for which to get the details for the nested inner GridView. If however I want to use server paging and sorting on the nested inner ObjectContainerDataSource then I am supposed to handle its Selecting event. But this event passes the ObjectContainerDataSourceView as the sender and with this I cannot get at the GridViewRow.DataItem to find the id for which to get the details for the nested inner GridView. If the Selecting event passed the ObjectContainerDataSource as the sender then I could get at the GridViewRow using the NamingContainer property of the ObjectContainerDataSource. Can anybody recommend how to implement this?


Jan 17, 2007 at 10:27 AM
I think the ObjectContainerDataSourceView should be given an Owner property that will return the ObjectContainerDataSource, or the ObjectContainerDataSource.Selecting event should raise its own event rather than attaching its event handlers to the ObjectContainerDataSourceView.Selecting event.


Jan 22, 2007 at 12:23 PM
I was hoping for a reply from the development team. Are you guys looking into this? I can of course modify the source code of ObjectContainerDataSource myself, but it would be better if this issue is resolved in your production code.

kind regards,

Jan 31, 2007 at 9:21 AM
hmmm, still no reply. Perhaps a little code example will illustrate the severity of the issue.

public partial class NestedGridView : BasePage<NestedGridViewPresenter>, INestedGridView {

private ObjectContainerDataSource _objectContainerDataSourceInner;

#region INestedGridView Members

public IList<OuterItem> OuterItems {
set { ObjectContainerDataSourceOuter.DataSource = value; }

public IList<InnerItem> InnerItems {
set { _objectContainerDataSourceInner.DataSource = value; }


protected void ObjectContainerDataSourceOuter_Selecting(object sender, ObjectContainerDataSourceSelectingEventArgs e) {
Presenter.OnOuterItemsSelecting(e.Arguments.StartRowIndex, e.Arguments.MaximumRows, e.Arguments.SortExpression);

protected void ObjectContainerDataSourceInner_Selecting(object sender, ObjectContainerDataSourceSelectingEventArgs e) {
ObjectContainerDataSourceView view = (ObjectContainerDataSourceView)sender;
_objectContainerDataSourceInner = view.Owner;
GridViewRow row = (GridViewRow)_objectContainerDataSourceInner.NamingContainer;
OuterItem outerItem= (OuterItem)row.DataItem;
Presenter.OnInnerItemsSelecting(outerItem, e.Arguments.StartRowIndex, e.Arguments.MaximumRows, e.Arguments.SortExpression);
_objectContainerDataSourceInner = null;



I have modified the ObjectContainerDataSourceView source code myself to add an Owner property. Without this I could not get at the GridViewRow through the NamingContainer property of the ObjectContainerDataSource and not get at the DataItem key for which to retrieve the data for the inner GridView. Hopefully this clarifies what I'm talking about and we can see the addition of this Owner property to the ObjectContainerDataSourceView in the next release.

kind regards,

Feb 1, 2007 at 7:59 PM
Hi Remco,
the Owner property approach seems to be a neat solution.
Thanks for creating an issue on this subject.

Discussion on this topic has been moved to Workitem 7837.

Juan Arguello