Master Pages and Data Sources

M

Mafuba

I'm trying to use data sources with data bound controls on one of my
pages that's using a master page. The master page has 2
ContentPlaceHolders, and in my page the data sources are in the first
content area, and the data bound controls are in the second. The data
bound controls are having a problem seeing the data sources at run time
(even though everything is picked up by the visual studio at design
time).

I get an error message similar to the following:
----------------------------------------
[HttpException (0x80004005): The DataSourceID of 'drpEmployee' must be
the ID of a control of type IDataSource. A control with ID
'EmployeeDataSource' could not be found.]
System.Web.UI.WebControls.DataBoundControl.GetDataSource() +194
System.Web.UI.WebControls.DataBoundControl.ConnectToDataSourceView()
+160
System.Web.UI.WebControls.DataBoundControl.OnLoad(EventArgs e) +17
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Control.LoadRecursive() +132
System.Web.UI.Control.LoadRecursive() +132
System.Web.UI.Control.LoadRecursive() +132
System.Web.UI.Control.LoadRecursive() +132
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+3695
----------------------------------------

After scouring the net for information on this error, I found that it's
most likely because the datasource is being loaded after the control
that's referencing it. When I move the datasource into the same
content area as the bound control, the control finds it.

It seems that the master page is parsing its ContentPlaceHolders in
arbitrary order. I don't know if this is by design or a bug in ASP.NET
beta 2, but if anyone has more info, insight, workarounds, etc. it
would be much appreciated.
 

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,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top