473,324 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Clearing a DropDownList

Vi
Hi,
Is there a way to clear a DropDownList from code behind, something similar
to myDropDownList.length=0 on the client?

Thanks.
Nov 18 '05 #1
4 19151
Hi,

This should work:

document.getElementById('dropdownlistname').option s.length = 0;

Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Vi" <Vi@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Hi,
Is there a way to clear a DropDownList from code behind, something similar
to myDropDownList.length=0 on the client?

Thanks.

Nov 18 '05 #2
In the code-behind, how about myList.items.clear?

"Vi" wrote:
Hi,
Is there a way to clear a DropDownList from code behind, something similar
to myDropDownList.length=0 on the client?

Thanks.

Nov 18 '05 #3
Vi
From the Code Behid, please...

Thanks,

"Ken Dopierala Jr." wrote:
Hi,

This should work:

document.getElementById('dropdownlistname').option s.length = 0;

Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Vi" <Vi@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Hi,
Is there a way to clear a DropDownList from code behind, something similar
to myDropDownList.length=0 on the client?

Thanks.


Nov 18 '05 #4
Vi wrote:
Hi,
Is there a way to clear a DropDownList from code behind, something similar
to myDropDownList.length=0 on the client?


The DropDownList has an Items property with methods for adding and
removing ListItems. There's Clear(), which will remove *all* items
(DDLID.Items.Clear()), and there's also methods like Add(), Insert(),
Remove(), and RemoveAt().

hth

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
Nov 18 '05 #5

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

Similar topics

2
by: John Smith | last post by:
Hi folks, I have a form with ASP.NET web controls. At the end of the form there's the "Clear" button to clear the available values and start over. How do I do that? The following did not work...
4
by: VB Programmer | last post by:
I have a dropdownlist which I populated on page_load. This works fine. I simply do a ddlMyDdl.Items.Add(xxx) I also have a button which references the CURRENTLY selected item in the ddl like...
2
by: PK9 | last post by:
Can someone help me with the syntax for clearing (removing) all items out of an asp:dropdownlist from the code behind? Is there a clear method? -- PK9
8
by: gv | last post by:
Ok, Hi all, new to asp.net. Simple question with web forms I have a Dropdownlist and a listbox, I want to click on and item in the dropdownlist and show items in listbox. that simple I...
4
by: Ali | last post by:
I used to clear my page's control in Visual Studio 2003 using code like this: Dim c As Control For Each c In Page.Controls(1).Controls If TypeOf c Is TextBox Then CType(c, TextBox).Text = Nothing...
1
by: renor321 | last post by:
Hello, I've searched the groups unsuccessfully to the solution to this problem. I've seen a few others making note of it, but it didn't seem like there were any solutions. I have a drop down...
7
by: Brad Pears | last post by:
I have something strange going on - pretty sure it used to work before - and now it does not... Why does the following code not clear a combo box? Me.cboLocation.Text = String.Empty OR ...
4
by: gobblegob | last post by:
I am trying to clear the array STR but it does not clear it. This sub is in a module. Dim STR As Array 'Dim str(6) As String STR =...
0
by: RajenderG | last post by:
in a page dropdownlist binding dynamically and assigned font color for few list items... and page having buttons .. when i click on button -- page post back happening and dropdown list items text...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.