473,385 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

content page subscriber to master page event doesn't update on 2nd postback

Hello All,

Here is my issue and thanks in advance for any assistance.

I have a base page with a dropdownlist that fires an event with
the selected index. The content page catches the event and sets
a connection string to the database. The content page has a
simple gridview that should show records from the selected
database. Initial content page displays data from correct place.
first change of dropdownlist correctly updates content page
gridview. any drop down list changes after that are ineffective.
I've attempted session state index saving in conjunction with
content page and master page load events during postback and not
postback. I've slimmed down to the basics to show my problem.
Here is the flow....

CP = Content Page
MP = Master Page

This is the first page load. The first four things listed here
happen every page.

CP::CP Constructor to content page
MP::MP Constructor to Master page
MP::MP_Init Master page init
CP::Page_Init Page INIT
(subscribe to select change event)

CP::Page_Load:NOTPostBack Initial call to page_load
CP::GridView1_DataBound bind it up and display records from
default db. this works to correct
database.

----------------------------------------------------------------------------------------------------
CP::Page_Load:PostBack the first postback
MP::CSDDL_SIC FIRED master page drop down changed by user
MP::Fire Index(1) master fires new index to content page
CP::Catch Index(1) content page catches
CP::GridView1_DataBound bind it up and display records from new
database. this works perfectly
----------------------------------------------------------------------------------------------------
CP::Page_Load:PostBack another post back to content page
MP::CSDDL_SIC FIRED master page drop down changed by user
MP::Fire Index(0) master fires new index to content page
CP::Catch Index(0) content page catches
*****Lack of LLT::GridView1_DataBound here and on all subsequent
dropdownlist changes*****

MASTER CODEBEHIND
public partial class MyMasterPage : MasterBase
{
public event ConnStrChangedEventHandler ConnStrChanged;

public MyMasterPage() {
Debug.WriteLine(String.Format("MP::MP"));
this.Init += new System.EventHandler(this.MyMasterPage_Init);
}

protected void CSDDL_SIC(object sender, EventArgs e) {
Debug.WriteLine(String.Format("MP::CSDDL_SIC FIRED"));
ConnStrChangedEventArgs CSCEA;
CSCEA = new ConnStrChangedEventArgs(CSDDL.SelectedIndex);
if (ConnStrChanged != null) {
Debug.WriteLine(
String.Format("MP::Fire Index({0})", CSCEA.Index));
ConnStrChanged(this, CSCEA);
}
}

private void MyMasterPage_Init(object sender, EventArgs e) {
Debug.WriteLine(String.Format("MP::MyMasterPage_In it"));
CSDDL.Items.Add(new ListItem("DEV1"));
CSDDL.Items.Add(new ListItem("ATLQA"));
CSDDL.SelectedIndex = 0;
}
}

CP(CONTENT) CODEBEHIND
public partial class CP : System.Web.UI.Page {
public CP() {
Debug.WriteLine("CP::CP");
this.Load += new System.EventHandler(Page_Load);
this.Init += new System.EventHandler(Page_Init);
}

protected void Page_Init(object sender, EventArgs e) {
Debug.WriteLine("CP::Page_Init");
Master.ConnStrChanged += new
ConnStrChangedEventHandler(Master_ConnStrChanged);
}

void Master_ConnStrChanged(object sender, ConnStrChangedEventArgs e)
{
Debug.WriteLine(String.Format("CP::Catch Index({0})", e.Index));
SqlDataSource1.ConnectionString =
ConfigurationManager.ConnectionStrings[e.Index + 1].ConnectionString;
}

protected void Page_Load(object sender, EventArgs e) {
if (IsPostBack) {
Debug.WriteLine("CP::Page_Load:PostBack");
}
else {
Debug.WriteLine("CP::Page_Load:NOTPostBack");
}
}

ENTIRE LISTING OF MASTERPAGE.MASTER FILE
<%@ Master Language="C#"
AutoEventWireup="true"
CodeFile="MasterPage.master.cs"
Inherits="MyMasterPage" %>
<html>
<head runat="server"><title>W</title></head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:contentplaceholder id="CP" runat="server" />
</td>
</tr>
<tr>
<td>Database</td>
<td>
<asp:DropDownList
ID="CSDDL"
runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="CSDDL_SIC" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

LLT.ASPX (Content Page) stripped
<%@ Page Language="C#"
MasterPageFile="~/MasterPage.master"
AutoEventWireup="true"
CodeFile="WF_STATUS.aspx.cs"
Inherits="LLT"
EnableSessionState="True" %>
<%@ MasterType TypeName="MyMasterPage" %>
<asp:Content ID="Content1"
ContentPlaceHolderID="CP"
Runat="Server">
<div>
<asp:GridView
ID="GridView1"
runat="server"
DataSourceID="SqlDataSource1"
OnRowDataBound="GridView1_RowDataBound"
OnDataBound="GridView1_DataBound" />
<asp:SqlDataSource />
</div>
</asp:Content>

Jul 27 '06 #1
0 2070

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

Similar topics

2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
6
by: MooreSmnith | last post by:
When I navigate to the next page using Response.Rediect("MyNextPage.aspx") current page Page_Load event is called. What I may wrongly understood is that post back will happen whenever there is any...
1
by: TCORDON | last post by:
I have a master page that has a public property IdCountry. This property is changed by a user control on the master page using a "Bubbled" event so the event is handled on the master page for other...
5
by: Federico | last post by:
I have a problem, I have an event declared in a Master Page, and I want to use in a Content Page holder of a Content Page. When I want to create the method to handle the event, I can njot reference...
8
by: William Buchanan | last post by:
Hi folks I have a "Search" text box and LinkButton in my master page. When this is submitted, I do a Server.Transfer to a page which contains a gridview. The gridview is filtered on a hidden...
0
by: Ben S | last post by:
vs2005, .net fw 2.0 the questions is, how can I cause the label to change in my client page triggered by an event raised from the user control which is on my master page. I have a master page...
2
by: Zetatec2 | last post by:
I have a site I am making. It contains one master page that has two ASP label controls and about sixteen ASP button controls on it. Then I have sixteen content or slave pages. The user clicks on...
2
by: BillE | last post by:
I am using master/content pages, with a treeview in my master page. When the selected node changed event fires in the treeview, I redirect to the requested content page associated with the...
8
by: Ben | last post by:
Hi, i'm trying to build a simple site navigation (using c#)... i implemented a master page that shows a sidebar user control on the left side, and a content page on the right. i click the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
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,...

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.