473,804 Members | 2,148 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 3592
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
1338
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
14833
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
9851
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
9967
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
4665
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
3504
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
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9593
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
10595
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
10343
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
10335
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
9169
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
5529
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
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3001
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.