473,796 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What exactly does dropdownlist.cl ear do...

I have a dropdown list bound to a datasource. I would like to clear it
at the press of a button. I tried using the following code:

mydropdown.Item s.Clear()

The end result is that it comes back unchanged.

I then thought to myself maybe it has to do with the viewstate so I I
kept adding more and more code until I ended up with the following:

ViewState.Clear ()
ClearChildViewS tate()
mydropdown.Auto PostBack = False
mydropdown.Enab leViewState = False
mydropdown.Item s.Clear()

Again, I just got my orignal list back. So does items.clear() not have
an effect on the control once it has been databound the very first
time.

Additionally, is it better to loop through all my controls and blank
them out, which would, if there is no fast method of clearing a drop
down list, mean looping through and removing each item from the drop
down list, OR to response.redire ct back to my page. When I say better
I mean faster to the end-user...

Thanks,
Ryan

Nov 19 '05 #1
2 3591
You aren't repopulating it in the Page_Load are you?
Make sure you are checking for IsPostBack

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Ryan" wrote:
I have a dropdown list bound to a datasource. I would like to clear it
at the press of a button. I tried using the following code:

mydropdown.Item s.Clear()

The end result is that it comes back unchanged.

I then thought to myself maybe it has to do with the viewstate so I I
kept adding more and more code until I ended up with the following:

ViewState.Clear ()
ClearChildViewS tate()
mydropdown.Auto PostBack = False
mydropdown.Enab leViewState = False
mydropdown.Item s.Clear()

Again, I just got my orignal list back. So does items.clear() not have
an effect on the control once it has been databound the very first
time.

Additionally, is it better to loop through all my controls and blank
them out, which would, if there is no fast method of clearing a drop
down list, mean looping through and removing each item from the drop
down list, OR to response.redire ct back to my page. When I say better
I mean faster to the end-user...

Thanks,
Ryan

Nov 19 '05 #2
Ryan,

How are you binding your list's items? Are the items being re-bound after
you clear it?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Ryan" <ry************ @kp.org> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
I have a dropdown list bound to a datasource. I would like to clear it
at the press of a button. I tried using the following code:

mydropdown.Item s.Clear()

The end result is that it comes back unchanged.

I then thought to myself maybe it has to do with the viewstate so I I
kept adding more and more code until I ended up with the following:

ViewState.Clear ()
ClearChildViewS tate()
mydropdown.Auto PostBack = False
mydropdown.Enab leViewState = False
mydropdown.Item s.Clear()

Again, I just got my orignal list back. So does items.clear() not have
an effect on the control once it has been databound the very first
time.

Additionally, is it better to loop through all my controls and blank
them out, which would, if there is no fast method of clearing a drop
down list, mean looping through and removing each item from the drop
down list, OR to response.redire ct back to my page. When I say better
I mean faster to the end-user...

Thanks,
Ryan

Nov 19 '05 #3

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

Similar topics

2
2378
by: xzzy | last post by:
Problem: the following creates an empty dropdownlist it needs to populate the dropdownlist with a list of printers global.aspx.cs++++++++++++++++++++++++++ string l_SQL = "SELECT modRowID, modPrinterName from tblPrinters WHERE modPrinterMfr = 1 ORDER BY modPrinterName ASC UNION Select 0 as aa, 'by Printer' as bb from tblPrinters;"; OleDbConnection myConnection = new
0
1634
by: Ashish Sharma | last post by:
I have a drop down list inside a data list on a form like this : <asp:DataList ID="DataList1" runat="server" EnableViewState="False"> <ItemTemplate> <asp:Label ID="lblname" Runat="server" text='<%# DataBinder.Eval(Container.DataItem,"Name") %>'> </asp:Label> <asp:DropDownList id="DropDownList1" runat="server" DataTextField="Name" DataValueField="UID" OnSelectedIndexChanged="CallMySub" AutoPostBack="True"></asp:DropDownList>...
7
1928
by: ÀÏÆÅ»³ÔÐ5¸öÔ | last post by:
I want use dropdownlist contral in gridview but have trouble now mycode here: i'm very sorry for my poor english <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1
1336
by: glenn | last post by:
Hi folks, I need to have two ddl's in one DataGrid cell. The first ddl has a list of company names and the second has a list of contact names that work in the company name that was selected in the first ddl. Any replies will be greatly appreciate. Here are 3 functions / subroutines that do the following:
11
14831
by: antonyliu2002 | last post by:
I know that this has been asked and answered thousands of times. As a matter of fact, I know that I need to say If Not Page.IsPostBack Then 'Do something End If for things that needs to be processed by the web server. I am still struggling to understand this postback logic, and hope that some kind gurus out there could help me clarify the confusion I have.
3
9849
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
Hi, Trouble in retaining values of dropdownlist, textboxes, and other controls when dropdownlist selectedindexchanged event is triggered, the controls are inside a user control and this user control inside a parent user control with an update panel. Can you guys help me hwo to retain the values. I have set EnableViewState to true. Where is correct page event to store entered and selected values before the values on controls are...
2
9960
by: sree reddy | last post by:
..cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls;
1
4662
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by pressing Remove button the selecetd row will be removed. I used viewstate to keep my value for postback, I want by changing selectedvalue of...
0
3502
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by...
0
9527
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
10223
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
10172
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
10003
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
9050
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...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
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

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.