473,738 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 INamingContaine r.
This class Load an ASCX control (that contains other controls in itself like
textbox and Dropdownlist). In the CreateChildCont rols 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(listItem s) . 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 INamingContaine r donde agrego aleatoriamente un ascx que quiera mostrar.
El problema es que despues que agrego el control ascx (en el
CreateChildCont rols) 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.
Jun 27 '06 #1
0 1632

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4772
by: Tom Bray | last post by:
Ok I am baffled I can not figure out this problem. I am getting the following error: Portal Error - A DropDownList cannot have multiple items selected. Error information Name Value Message A DropDownList cannot have multiple items selected. Source System.Web TargetSite Void RenderContents(System.Web.UI.HtmlTextWriter)
4
4829
by: George | last post by:
I'm using .NET framework 1.1 and VS.NET 2003 for a aspx web form. There is a DropDwonList on the page and its SelectedIndexChanged event is fired to the server normally, until when I add another form "FormDummy" onto the main form, and then the event no longer fires again when the user change the value of the drop down list. Can anybody help ? Thanks so much! The aspx code is as follows:
3
3343
by: Maziar Aflatoun | last post by:
Hi everyone, I have the following code <asp:TemplateColumn HeaderText="Administator" Visible="True" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:Label ID="IsAdministator" Runat="server" text='<%# FormatIsAdministator(DataBinder.Eval(Container.DataItem, "IsAdministator")) %>'> </asp:Label>
3
1822
by: TJS | last post by:
I am rendering a dropdownlist from HTMLTextWriter, how do I specify to enable autopostback ? '========================================= .... writer.AddAttribute(HtmlTextWriterAttribute.Id, "xx") writer.AddAttribute(HtmlTextWriterAttribute.Name, "xx") writer.RenderBeginTag(HtmlTextWriterTag.Select) writer.AddAttribute( HtmlTextWriterAttribute.Value, "-1" )
1
3616
by: Stefano Napafini | last post by:
As subject, how could I change the layout of an asp:dropdownlist webcontrol so that it appears flat (single border, no 3d look...). Probably it's a very naive question, but I've started using asp.net just now...and sorry for the mistakes due to my bad english...
3
1525
by: Mark Rae | last post by:
Hi, Apologies, but I appear to be having a senior moment... I have a standard DropDownList webcontrol with a SelectedIndexChanged event, as follows: <asp:TableCell ColumnSpan=4 VerticalAlign=Middle> Select your delivery location: <asp:DropDownList ID="cmbShipping" Runat="server"
1
7463
by: Eric W. Holzapfel | last post by:
Hello Group, As far as a dropdownlist, is there a way to access both values for the datatextfield (like a name, etc) AND the value of the datavaluefield (like a record number, or index etc). the dropdown list is populated by a query to a datbase table. loaded with a datareader like below: Dlist.DataSource = myCommand.ExecuteReader(); Dlist.DataTextField = TextField; (this would be a name, "Jones Inc.")
0
1049
by: RBM007 | last post by:
Hello, I have created webpages in the atlas standard. To help my users, I automaticaly focus to the first editable control which is in a GridView kind control. Every gridview is placed in a UpdatePanel which is recently translated from Atlas to AJAX. Before the translation everything works perfectly, but after the translation I got problems with calling focus. Here some code:
3
2205
by: Victor | last post by:
Hi guys. I want to implement a customized user webcontrol (.ascx). Inside this control I have a dropdownlist and a button. when user click the button, it will open a pop up window(not Ajax popup window). The popup window will display a datagrid. The user can select one or more items from the datagrid. Then when they close the pop-up window, the system will add user's selection into the dropdownlist inside the parent page. How can I...
0
8787
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9473
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9259
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6750
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.