M
Mark Olbert
This involves a family of related, databound ASPNET2 composite controls.
I've managed to arrange things so that the composite controls restore themselves from ViewState on postback after they're initially
configured during DataBind(). Thanks to Steven Cheng for pointing out that you have to set the constituent control properties after
you add them to the composite control collection for the restore to work!
However, I now have a different problem. At least, I think it's a different problem.
One of the composite controls is a collection of HtmlInputRadioButton controls. All are initially unselected. When I select a
particular HtmlInputRadioButton and do a simple postback (i.e., just a roundtrip to the server; no other processing takes place) the
page that reappears doesn't show the selection. Instead, all the HtmlInputRadioButton controls in that composite control are
unselected again.
But here's the weird part: if I make the selection again -- or indeed any selection, from any of the other, related composite
controls on the same page -- and do a postback, the selection(s) show up! For some reason, the very first selections, whatever they
are, don't get stored. But the ones on subsequent roundtrips do.
I find this very confusing. I think this may mean there's something wrong with the way in which the controls are initialized when
first created (i.e., through DataBind()), but I'm not sure. Or does it mean that I have to do some postback handling? But if so, why
does the Framework appear to take care of things on the subsequent roundtrips?
Can anyone suggest some ideas on what may be causing the behavior? And how I fix it?
- Mark
I've managed to arrange things so that the composite controls restore themselves from ViewState on postback after they're initially
configured during DataBind(). Thanks to Steven Cheng for pointing out that you have to set the constituent control properties after
you add them to the composite control collection for the restore to work!
However, I now have a different problem. At least, I think it's a different problem.
One of the composite controls is a collection of HtmlInputRadioButton controls. All are initially unselected. When I select a
particular HtmlInputRadioButton and do a simple postback (i.e., just a roundtrip to the server; no other processing takes place) the
page that reappears doesn't show the selection. Instead, all the HtmlInputRadioButton controls in that composite control are
unselected again.
But here's the weird part: if I make the selection again -- or indeed any selection, from any of the other, related composite
controls on the same page -- and do a postback, the selection(s) show up! For some reason, the very first selections, whatever they
are, don't get stored. But the ones on subsequent roundtrips do.
I find this very confusing. I think this may mean there's something wrong with the way in which the controls are initialized when
first created (i.e., through DataBind()), but I'm not sure. Or does it mean that I have to do some postback handling? But if so, why
does the Framework appear to take care of things on the subsequent roundtrips?
Can anyone suggest some ideas on what may be causing the behavior? And how I fix it?
- Mark