473,472 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Master Page databinding issue

I know what's causing this, but how do I work around it?

**********************
file: test.master:
**********************

<%@ Master %>
<script runat=server>
void Page_Load(object sender, EventArgs e)
{
DataBind();
}
</script>
**<asp:ContentPlaceHolder runat=server id=main />**

**********************
file: test.aspx
**********************

<%@ Page MasterPageFile="test.master" %>
<script runat=server>
public override void DataBind()
{
throw new Exception();
}

string Expression = "I am Databound";
</script>
<asp:Content runat=server contentplaceholderid=main>
<%# Expression %>
</asp:Content>

**********************
Problem
**********************

DataBind is never called on the aspx file, yet databinding expressions
are still processed. I imagine what's happening is this:

Master page finds all the <asp:content ...controls in the page file.
Removes them and loads them into the master page a la:

foreach(Control c in LoadedPage.Controls)
{
Content content = c as Content;
if (content == null) continue;

this.FindControl(content.ContentPlaceHolderID).Con trols.Add(content);
}

//discard the (aspx) page loaded into memory

DataBind the master page.

There is one thing that I'm missing, and that is if I manually call
"DataBind()" within the page, that databind expression is called as
well. I can't call DataBind() at both the master and the page level
without having it fire twice. Did Microsoft give us a delegate that I
can wire up to to get around this?

-Alan

Jul 25 '06 #1
1 2230
There is one thing that I'm missing, and that is if I manually call
"DataBind()" within the page, that databind expression is called as
well. I can't call DataBind() at both the master and the page level
without having it fire twice. Did Microsoft give us a delegate that I
can wire up to to get around this?
A bit of un asked for advice, it seems to be better to databind things
individually rather then using a global databind event.

like:

Datagrid1.DataSource = datatable1
Datagrid1.DataBind()

This way you will avoid any unwanted triggering of the DataBind.
Jul 25 '06 #2

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

Similar topics

7
by: Martijn Saly | last post by:
Hi there, I've created a master page with some controls on it, a Calendar control among others. Now depending on the date(s) selected, the content page needs to be updated. In the masterpage...
2
by: Jon Spivey | last post by:
Hi, Using VS 2005/VB.net. I need to add a meta description tag and change a stylesheet link from a page based on a master page. Found this article...
0
by: Sam | last post by:
Folks, Attached I am sending 2 URL's from MSFT ASP.net Quick Start Tutorial Web Site. 1) Run it URL: http://www.asp.net/QuickStart/aspnet/samples/data/GridViewMasterDetailsInsertPage_vb.aspx 2)...
1
by: Sam | last post by:
Attached I am sending 2 URL's from MSFT ASP.net Quick Start Tutorial Web Site. 1) Run it URL: http://www.asp.net/QuickStart/aspnet/samples/data/GridViewMasterDetai... 2) View Source URL:...
0
by: Sam | last post by:
Sorry to post the same post multiple times but the URL Addresses were not Correct in Earlier Posts. Here are the correct URL's: 1) Run It URL is here: ...
11
by: EagleRed | last post by:
I am writing an ASP.NET 2.0 application that uses master pages. I have some pages that must not be cached on the client. In ASP.NET 1.1 I achieved this using metatags: <meta...
3
by: William Youngman | last post by:
I am on a team that is developing a proposal generation web application and we are using a custom base page (ProGenBase.cs) located in the app_code directory and all of the app's web pages inherit...
0
by: Mike Wilson | last post by:
Dear group, I have an invoice entry form, which is a simple Master fields / Detail grid. The main summary information of the invoice are stored in one table in a dataset, which is bound using a...
3
by: Steve B. | last post by:
Hi, I've build a corporate application that have a dozen of pages that use a master page. I'd like to add in each page a list of possible actions in a "task pane". The design of this pane is...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
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,...
1
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...
0
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...
0
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...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.