How to "track" a (child) control's ViewState / SaveViewState?

T

Teemu Keiski

Can you post the code? It is hard to say anything exact before that? Do you
bind the DDL *after* it is added to the Controls collection of your parent
control?
 
Z

Zarko Gajic

Hi, I'm developing a composite control that accepts other controls using
PersistChildren(true).

Now, for some unknown reason the ViewState of a DropDownList child control
is not saved.

For example: a DropDownList is binded with some collection using "if NOT
Postback ...", after a postback the data in the DropDownList is lost ....

I've overridden DropDownList to see what's happening in SaveViewState ...
and guess what ... the ArrayList the DropDownList is binded from is NOT
saved ... why?

Before I start digging deep using Reflector can someone shed some lights on
the internal workings of the DropDownList's "SaveViewState"...?

p.s.
I'm pretty sure it has to be something with the inner workings of my
composite control .. but am unsure where to look for the problem.

~Zarko
 
M

microsoft.newsgroups.com

Temmu,

the code is to much complex to be posted here :(

The DropDownList is placed between the start and the end tag of my control,
in the aspx, something like

<cc1:mycontrol ...>
<asp:dropdownlist ...>
</cc1:mycontrol>

The DropDownList is being populated in Page_Load inside the "if NOT
Postback" block ...

To try to track where and when the ViewState of the DropDownList is lost
I've done the following

1. Created MyDropDownList by simply inheriting from DropDownList
2. Overrided the SaveViewState, just to be able to see if Items are saved in
the view state
3. Break Point placed at the end of the overridden SaveViewState gives the
following info:
a) Items property has 4 items I've added in the Page_Load, BUT
b) the Second parameter of the ViewState Triplet is empty!


I've then placed MyDropDownList directly on the Page, ... checked the saved
ViewState ... the "Second" parameter of the Triplet inside the ViewState
holds my items!


Summary: for some unknown reason the ViewState of the DropDownList is not
"populated" with the Items property, when the DropDownList is placed in my
custom control.

p.s.
Thank you for answering, I hope the above helps.

~Zarko
 
Z

Zarko Gajic

Hi.

Problem solved with the help of (even though it was not that trivial):

http://scottonwriting.net/sowblog/posts/2129.aspx

~zarko


microsoft.newsgroups.com said:
Temmu,

the code is to much complex to be posted here :(

The DropDownList is placed between the start and the end tag of my control,
in the aspx, something like

<cc1:mycontrol ...>
<asp:dropdownlist ...>
</cc1:mycontrol>

The DropDownList is being populated in Page_Load inside the "if NOT
Postback" block ...

To try to track where and when the ViewState of the DropDownList is lost
I've done the following

1. Created MyDropDownList by simply inheriting from DropDownList
2. Overrided the SaveViewState, just to be able to see if Items are saved in
the view state
3. Break Point placed at the end of the overridden SaveViewState gives the
following info:
a) Items property has 4 items I've added in the Page_Load, BUT
b) the Second parameter of the ViewState Triplet is empty!


I've then placed MyDropDownList directly on the Page, ... checked the saved
ViewState ... the "Second" parameter of the Triplet inside the ViewState
holds my items!


Summary: for some unknown reason the ViewState of the DropDownList is not
"populated" with the Items property, when the DropDownList is placed in my
custom control.

p.s.
Thank you for answering, I hope the above helps.

~Zarko
 

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,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top