473,396 Members | 1,852 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,396 software developers and data experts.

DropDownList not allowing SelectedIndex = -1

Ok I'll start out with I found:

http://support.microsoft.com/kb/327244/
BUG: ComboBox Does Not Clear When You Set SelectedIndex to -1

Ok so in HTML you can have:

<select id="MyList">
<option value="1">1
<option value="2">2
<option value="3">3
</select>

And in javascript you can set MyList.selectedIndex = -1 which will display
the dropdown with nothing selected.

I'm using .NET 1.1 and this doesn't work? WHY? Why has there been no fix
for this that I can find. The ListBox control allows the SelectedIndex = -1
and shows the list with nothing selected but the Dropdownlist control reverts
to SelectedIndex = 0 when you set it to -1 and always shows the first item
selected.

Yes I know I could add a blank item to the list but that's not the point.
Microsoft Obviously knows there a bug but hasn't fixed it. Even the work
arounds do not work.

Anyone have any comments or solutions about this.
Nov 19 '05 #1
2 2755
there is no html solution for this as the selectedItem is not exposed.
client script is required, probably why asp.net does not support it.

<asp:listbox id=listBox1 runat=server>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:listbox>
<script>
document.getElementById('<%=listBox1.ClientID%>'). selectedIndex=<%=listBox1.selectedIndex%>;
</script>
-- bruce (sqlwork.com)

"MrSmoofy" <Mr******@discussions.microsoft.com> wrote in message
news:E5**********************************@microsof t.com...
Ok I'll start out with I found:

http://support.microsoft.com/kb/327244/
BUG: ComboBox Does Not Clear When You Set SelectedIndex to -1

Ok so in HTML you can have:

<select id="MyList">
<option value="1">1
<option value="2">2
<option value="3">3
</select>

And in javascript you can set MyList.selectedIndex = -1 which will display
the dropdown with nothing selected.

I'm using .NET 1.1 and this doesn't work? WHY? Why has there been no fix
for this that I can find. The ListBox control allows the SelectedIndex
= -1
and shows the list with nothing selected but the Dropdownlist control
reverts
to SelectedIndex = 0 when you set it to -1 and always shows the first item
selected.

Yes I know I could add a blank item to the list but that's not the point.
Microsoft Obviously knows there a bug but hasn't fixed it. Even the work
arounds do not work.

Anyone have any comments or solutions about this.

Nov 19 '05 #2
Your wrong sorry to tell you.

For a list box SelectedIndex = -1 works fine as expected but for a
dropdownlist it doesn't however it should and according to the bug report
from Microsoft they knew it was a problem in .NET 1.0 and had a workaround
but in 1.1 the workaround doesn't work and the bug is still there.

"Bruce Barker" wrote:
there is no html solution for this as the selectedItem is not exposed.
client script is required, probably why asp.net does not support it.

<asp:listbox id=listBox1 runat=server>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:listbox>
<script>
document.getElementById('<%=listBox1.ClientID%>'). selectedIndex=<%=listBox1.selectedIndex%>;
</script>
-- bruce (sqlwork.com)

"MrSmoofy" <Mr******@discussions.microsoft.com> wrote in message
news:E5**********************************@microsof t.com...
Ok I'll start out with I found:

http://support.microsoft.com/kb/327244/
BUG: ComboBox Does Not Clear When You Set SelectedIndex to -1

Ok so in HTML you can have:

<select id="MyList">
<option value="1">1
<option value="2">2
<option value="3">3
</select>

And in javascript you can set MyList.selectedIndex = -1 which will display
the dropdown with nothing selected.

I'm using .NET 1.1 and this doesn't work? WHY? Why has there been no fix
for this that I can find. The ListBox control allows the SelectedIndex
= -1
and shows the list with nothing selected but the Dropdownlist control
reverts
to SelectedIndex = 0 when you set it to -1 and always shows the first item
selected.

Yes I know I could add a blank item to the list but that's not the point.
Microsoft Obviously knows there a bug but hasn't fixed it. Even the work
arounds do not work.

Anyone have any comments or solutions about this.


Nov 19 '05 #3

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

Similar topics

2
by: rmorvay | last post by:
I am trying to dynamically build a dropdownlist and bind it to a cell in a grid. I tried to utilize the following code but I am stuck at the point where I bind the dropdownlist to the grid cell. ...
7
by: Mike D | last post by:
I've databound the dropdownlist. How do I prevent it from selecting the first item in the list during page load.
4
by: skyking1 | last post by:
I have a web form in which I'm selecting values of 10 different dropdownlists using a for each. I use DirectCast along with FindControl to get each dropdown and set the value. It seems that setting...
3
by: Tim::.. | last post by:
Can someone please tell me how I go about preselecting an item in a drop drown list when I click the Edit Command in a datagrid? I have tried the following but it doesn't work for me! I would...
4
by: Mark Waser | last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a datagrid. In the page PreRender step, the selected index of the datagrid is successfully set during databinding. Yet,...
3
by: S_K | last post by:
Hi, I have a list of 6 DropDownList boxes, from DropDownList1 to DropDownList6, and I'm changing the SelectedIndex of each using a foreach loop as follows: foreach(PaymentReqDisplay...
1
by: spamguy | last post by:
I have a DataGrid and a column that changes into a DropDownList when edited: <columns> <asp:templatecolumn headertext="Role Type"> <itemtemplate> <asp:hyperlink id="hlinkRoleType"...
1
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...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.