473,898 Members | 2,914 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multiple asp:content's requires multiple datasources?

Hi guys

Just a general query regarding using the AccessDataSourc e within a website
which uses a MasterPage.

The layout of my content page is as follows...

<asp:Content ID="Content1" ContentPlaceHol derID="cphConte nt" Runat="Server">
<h1><asp:Labe l runat="server" Text='<%# Eval("StoryTitl e") %>"
ID="lblHeading " />
</h1>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHol derID="cphSideb ar" Runat="Server">
<!-- more Evals and content -->

<!-- data access -->
<asp:AccessData Source ID="adsStory" runat="server"
DataFile="~/App_Data/data.mdb"
SelectCommand=" SELECT [StoryTitle] FROM [Stories]
WHERE ([StoryID] = ?)">
<SelectParamete rs>
<asp:QueryStrin gParameter Type="Int32"
QueryStringFiel d="id" />
</SelectParameter s>
</asp:AccessDataS ource>
</asp:Content>

The problem is that in order to make the databinding work in Content1, I
actually have to create a seperate AccessDataSourc e object WITHIN Content1.
If I put the AccessDataSourc e outside the content(s), VS won't compile it.

The only way round is, as I say, to either create 2 datasources (one for
each content), which surely will impact on the level of database activity,
speed, etc? Or alternatively, to use code-behind databinding.

The obvious answer is "just use code-behind") but I feel like I'm missing
something... surely there is a way to have multiple content areas on a
MasterPage child and only use 1 datasource across both? (while still being
able to do it without code-behind) ..?

Thanks

Dan
Feb 19 '07 #1
4 2019
Hi,

Unfortunately the Master Page and the Content Page will not be able to
access each other's control directly. You will have to use FindControl (and
probably need to use it recursively) to access control on the other part.
For DataSourceID data binding to work, the data source control must exist
either in the same naming container as the data listing control that
references it, or in a parent control of the data listing control:

#BaseDataList.D ataSourceID Property (System.Web.UI. WebControls)
http://msdn2.microsoft.com/en-us/lib...rols.basedatal
ist.datasourcei d.aspx

For controls inside a master page and a content page, they're in different
container. Turn on "Trace" of your master page to see the control tree.

Therefore, I'm afraid you will have to resort back to the code-behind
workaround.

Hope this helps.

Sincerely,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.
Feb 20 '07 #2
Sorry, I was replying too quick.

A few corrections to my previous reply:

1) "Trace" option is only available in your content page.

2) The data source control could be placed on your master page and you can
use it in your content page using DataSourceID; but not vice-versa.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 20 '07 #3
Hi Walter,

Thanks for the explanation - I think I'm with you. Just to clarify...

1) to use a datasource within 2 containers (asp:content's) , I have to do
that via code in the code-behind.

2) Alternatively, I could place the datasource in the masterpage and it
would be accessible by both asp:content containers through the control tree?
(the problem there is that I only want the datasource on 1 page, not every
page which uses the master page!)

Makes more sense now, thanks!

Dan

"Walter Wang [MSFT]" wrote:
Sorry, I was replying too quick.

A few corrections to my previous reply:

1) "Trace" option is only available in your content page.

2) The data source control could be placed on your master page and you can
use it in your content page using DataSourceID; but not vice-versa.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 20 '07 #4
Hi Dan,

1) If you put a data source control in your content page, you will have to
use code-behind to bind it to a control which resides in your master page.
See the trace output to learn the control tree hierarchy and read the
documentation of DataSourceID for more information.

2) If you put a data source control on your master page, yes every content
page that is using this master page will be able to use that data source
control's ID in ASPX to bind the data source. However, I don't think this
is a problem if you only need it only on one content page and the master
page.
Please feel free to let me know if you need anything else.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 21 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
1672
by: John | last post by:
Greetings, I was talking to my host company representative this evening, and he thought that certain web crawlers (he mentioned Offline Explorer /and/ Anawave WebSnake would be able to download the actual ASP pages rather than simply downloading the page as modified by IIS. Is this true? Or is my actual ASP code safe from viewing? I'd hate to think that someone could download the code that creates my
3
1301
by: robin9876 | last post by:
In an asp.net (VB) web page I have created a HTML table that has some server side labels which has information populated to at runtime from code. This works for when there is only one recorded returned form the database. When two or more records are returned how can I create an additional copy of this output with the data from the other records?
3
1710
by: Gerhard | last post by:
Is it possible to embed a .pdf file inside <asp:Content></asp:Content>? I have a page that has a master page with navigation, etc., and I want the content to be what is in a .pdf file. Is this possible? If so, how can I do it? Thanks.
2
2269
by: Victor Rodriguez | last post by:
I need a way to be able to retrieve child controls on a <asp:Content I've try I get nothing. Where should I look? thanks, Vic
4
1396
by: Janto Dreijer | last post by:
Hi! The Nokia Java SDK allows one to define multiple content-types in a single HTTP header field. I'm not sure if it's standard, but it's happening from some Java-enabled phones. This breaks the FieldStorage class in cgi.py by not causing self.read_urlencoded() to be called at object init. Specifically when one gets a type value like 'text/plain, application/x-www-form- urlencoded'.
3
2125
by: MikeB | last post by:
Hello, I have a content page that is from a Master page which has 2 content panes. How do I add my forms to the content page? Each pane needs a form but you can not have multiple form tags nor can the form tages be outside of the content tags? Does this make since? Below is my source to the pages. Basically I need both content tags to have form tags.
1
2502
by: Joe Kovac | last post by:
Hi! I use: <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <link rel="stylesheet" href="../javascript/my.css" /> <script src="../javascript/my.js" type="text/javascript" /> ...
5
2038
by: fran7 | last post by:
Hi, I have set up a next navigation with this code <% Set NextLink = Server.CreateObject ("MSWC.NextLink") %> <A HREF="<%= NextLink.GetNextURL ("/links.txt") %>">Next Page </A> and a .txt file like so submit2.asp
1
1593
by: baburk | last post by:
Hi, How to refresh only a particular asp:Content for certain period of time. How can i? <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> </asp:Content>
0
9993
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10946
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9658
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8034
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7187
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5877
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3303
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.