Re: Why can't I set the listbox selectedIndex to -1?
- From: bruce barker <nospam@xxxxxxxxxx>
- Date: Thu, 26 Apr 2007 12:36:02 -0700
this can only be done in javascript. in html if you render a select with no option set as selected, it defaults to the first. in javascript you can set the selectedIndex to -1 which will unselect.
you can subclass the listbox, and have it generate the required javascript.
-- bruce (sqlwork.com)
amtamayo@xxxxxxxxx wrote:
I have a simple webform that has a listbox that I bind to a dataview.
at designtime. This provides an optional selection for the user so I
wanted to have no default value selected. So on the Page_Load event,
I set the selectedIndex to -1. However, when I run the page, the
default value is still 0, which forces the first item to be
automatically selected. I tried a bunch of things. I tried setting
it to 0, then -1. I tried to call ClearSelection() then set it to -1,
but no avail. This is a listbox, for crying out loud! This ought to
be simple, but is not.
Need help.
- References:
- Why can't I set the listbox selectedIndex to -1?
- From: amtamayo
- Why can't I set the listbox selectedIndex to -1?
- Prev by Date: Re: Question about ASP.NET threads: nuts & bolts
- Next by Date: webdev.webserver fails to start
- Previous by thread: Re: Why can't I set the listbox selectedIndex to -1?
- Next by thread: Dotnet framework 3.0 questions
- Index(es):
Relevant Pages
|
Loading