XmlDataSource in master page

  • Thread starter Thread starter zvickery
  • Start date Start date
Z

zvickery

Currently I have a project where multiple pages share a master page and
also share a common XmlDataSource. Within the various pages, there are
controls (such as DropDownLists) that I would like to bind to the
common data source using the design-time DataSourceID property.
However, I have been unable to find a way to have a content page's
control successfully reference the XmlDataSource from the master page.


The problem is basically that bound control's DataSourceID expects a
string containing the name of an object within the control's class. Of
course, it is not possible to directly reference controls on the master
page. My question is whether there is indeed a way to share a data
source between pages (ideally using master pages) or if there might be
another workaround possible?

Thank you!
 
You could create another DataSourceProvider (i.e. GlobalDataSourceResolver)
that can call Page.FindControl(...) and provide the XmlDataSource's data to
the control as if it were its own. There may be a better way, but I've been
immersed in WPF lately, and I KNOW it solves that issue via hierarchical
resource scoping, but it's muddled my ASP.Net memory a bit.
 
Back
Top