Thanks Cathal for the link. It helped me understand the page process flow and why controls need to be added in the Init phase. However, that is where I am loading the controls, but viewstate still is not persisting. Here are some code snippets.
As an overview of what I've got:
1. LoadControl.ascx - based on reading query string parameters, determines whether to load the master or the detail .ascx.
2. Master.ascx
3. Detail.ascx
Here is the applicable code in LoadControl.ascx:
01.
Inherits
Entities.Modules.PortalModuleBase
02.
03.
Private
Sub
Page_Init(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Init
04.
Call
LoadDynamicControl()
05.
06.
End
Sub
07.
Public
Sub
LoadDynamicControl()
08.
Dim
controlToLoad
As
Control
09.
10.
Try
11.
12.
Dim
intID
As
Integer
= Convert.ToInt32(Request.QueryString(
"ID"
))
'A dyno link was clicked
13.
14.
If
intID > 0
Then
15.
controlToLoad =
Me
.LoadControl(
"Controls/Details.ascx"
)
16.
Else
17.
controlToLoad =
Me
.LoadControl(
"Controls/Master.ascx"
)
18.
End
If
19.
20.
Me
.Controls.Add(controlToLoad)
21.
phViewControl.Controls.Add(controlToLoad)
22.
23.
Catch
exc
As
Exception
'Module failed to load
24.
ProcessModuleLoadException(
Me
, exc)
25.
End
Try
26.
End
Sub
On the Detail.ascx page, a panel is displayed with a detailview control that has a cascading ddl. When you change the parent ddl, a postback is initiated to set the value of the dependent ddl. However, when the page comes back from the postback, the parent ddl has gone back to its default selection and the child ddl is set to it's default selection.
As I am loading the control in the Init phase, how come viewstate is not being maintained?
Thanks,
Chad