Complex Custom Control Conundrum

I

Iain

Can I apologise for the lengthy nature of this post. The scenario is
complicated (though I hope the solution is not!)

basically, I've got a custom template control which binds itself to a tree
structure. The template items describe how each particular note type of
the tree should be rendered (the nodes are data capture elements - bool
string and more complicated things).

I don't want to use ViewState because of size (there are potentially
hundreds of elements on the page).

So what I do is to perist a key to the root node in the viewstate and the
recreate and bind the control heirarchy in the LoadViewstate and see what
changes have been made from the postback data. I do this in the OnLoad
method by reading recursively scanning the control tree looking for certain
control names and updating the corresponding tree node data element if
needed.

Finally, if I need to I will tear down the control tree and recreate a new
one.

This was all more or less working until I added a new custom control type.

This custom control wraps a DropDownList which is to be populated from the
node of my data structure. I need to record the selected item which I do
with a custom property and handling LoadPostData to get the correct value
for this from the PostCollection (which should later be picked up by OnLoad
routine).

And to the problem. Well, depending on some niceties, I seem to have a
choice of not creating the control tree (that is CreateChildControls is not
called) for this particular custom control and having LoadPostData called
(with no control name so no way to find hte correct post data) or having
the control created but not having the LoadPostData method called. The
template handler for the element is called, but the DropDownList does not
appear to be created at that point because the reference to the tree node
which it needs has not been bound.

Now, having said all that, since I started moving code around, it looks
like none of the changes are been found, which may be that no LoadPostData
calls are being made in the postback (more or less, I've moved the control
creation from OnLoad back into LoadViewState).

If any of this rings a bell, I'd be grateful for any pointers!


Iian
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top