ViewsState, DropDownList and WebControl



Hello
First of all, excuse my english

We all know that in a normal page with codebehind we add a dropdownlist
control and we bind() it in the (!ISPOSTBACK), so, we don't need to go to
database again 'cause its value are saved (i assume viewstate).

Well. I have a class that inherits from WebControl and INamingContainer.
This class Load an ASCX control (that contains other controls in itself like
textbox and Dropdownlist). In the CreateChildControls i add the ascx and
initialize its inner controls (by FindControl method). So, i override the
DataBind() and if it's not postback, then i bind() the dropdownlist. this
works right, BUT if there is any postback, it doesn't load its
values(listItems) . The textbox keeps its value. I have been reading that
some people override LoadViewState and SaveViewState in order to persits
Attributes inside the listItems. Is there anything i can do to make my
dropdownlist persists its values so i don't have to load from database
everytime there is a postback?

Can anybody help me on this?
Thanks in advance


Ahora. mi problema es el siguiente. Tengo una clase que hereda de WebControl
y INamingContainer donde agrego aleatoriamente un ascx que quiera mostrar.
El problema es que despues que agrego el control ascx (en el
CreateChildControls) y le inicializo sus controles internos (como textbox,
dropdown, etc.).
hago un override del metodo DataBind y alli le paso el datasource que es un
arraylist que saco de una base de datos si NO ES POSTBACK. El tema es que
cuando hay un postback de nuevo en mi pagina, el textbox mantiene su valor
pero el dropdown me sale completamente vacio. Pierde sus valors. hay algo
que estoy haciendo mal? Se que haciendo overrides del LoadViewState y
SaveViewState se resuelve. Lo he leido. pero no he podido hacerlo funcionar.
Alguien tiene idea?
Ayuda Por Favor. estoy vuelto loco con esto.


.



Relevant Pages

  • RE: Composite control, postback and change control tree
    ... postback value of the dropdownlist - ie. we are *changing* the control tree ... When the first dropdown ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: asp:DropDownList and Javascript
    ... Would it also be acceptable to update the first dropdown AutoPostBack=TRUE, ... items for the second control? ... elements, however, after you postback the page, the page will recreate the ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.languages.csharp)
  • HELP! dropdown control is being reset to a value on every postback!
    ... resetting to the 2nd value on the list anytime a postback occurs. ... I have EnableViewState set to true for the control - the control stays ... I have tried disabling the autoPostBack of the dropdown, ... On both screens I have deleted the controls and dragged on ...
    (microsoft.public.dotnet.framework.aspnet)
  • HELP! dropdown resets to a specific value on postback! (asp.net.vb)
    ... resetting to the 2nd value on the list anytime a postback occurs. ... I have EnableViewState set to true for the control - the control stays ... I have tried disabling the autoPostBack of the dropdown, ... On both screens I have deleted the controls and dragged on ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: Create control with drop-down similar to ComboBox
    ... problem (more or less I am changing the control size on dropdown, ... a parent large enough to hold the entire dropdown). ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... private void button1_Click ...
    (microsoft.public.dotnet.framework.windowsforms)