Access Masterpage SQLDatasource

  • Thread starter Thread starter Gaspar
  • Start date Start date
G

Gaspar

I have a MasterPage with a SqlDatSource named "myDS".
In a content page placed inside a ContentPlaceHolder I have a GridView that
I need to connect to myDS.

The problem is that "myDS" is not listed in the GridView's "Choose Data
Source" list. If I force it to "myDS", I can access the data in runtime
(i.e. the page runs OK), but the designer doesn't show the columns, data,
etc., to design the GridView.

Any ideas?
Thanks!
 
I don't know a simple solution. If I had to do this, I'd expose a property
in the master page that returns the data source. You could then reference
the Master property and type cast it to your master page in your content
page's Load event and set the GridView's data source.

Beyond that, it's hard for me to think of a case where it makes sense to put
a datasource in the master page unless the data is also being displayed from
the master page. FWIW, I wouldn't think twice about duplicating a data
source on different pages if I needed the same data on both pages.

Don't know if that's any help though.
 
Back
Top