Custom Control - Inheriting from Panel

saxyannuast

New Member
I'm trying to author my own server control but run into strange problem. I have following class inherited from panel<BR><BR>class myContainer : Panel {}<BR><BR>Then I have another control also inherited from panel<BR><BR>class myTotalContainer : Panel {<BR> protected override void CreateChildControls() {<BR> // PROBLEM LIES IN THE NEXT LINE<BR> this.Controls.AddAt(0, new LiteralControl("test"));<BR>}<BR>}<BR><BR>In my aspx I have something like this.<BR><BR><custom:MyTotalContainer><BR> <custom:myContainer><BR> form fields and some literal content<BR> </custom:myContainer><BR></custom:MyTotalContainer><BR><BR>Everything (viewstate, events etc) works fine when myContainer has only literal content and form fields like textboxes etc. BUT, when I have <asp:dropdownlist> and use databinding to populate it - it loses its viewstate. When I comment out the line where literal control is added - also dropdownlist works. I think problem is at databinding, somehow viewstate is not maintained when I add literal control. Is there some solution to this?<BR><BR>Regards,<BR>Tuukka
 
Back
Top