By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,028 Members | 1,316 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,028 IT Pros & Developers. It's quick & easy.

Clearing a DropDownList

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.