Access Masterpage SQLDatasource

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

Jonathan Wood

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.
 

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,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top