Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DropDown List Default Selected Item

Reply
Thread Tools

DropDown List Default Selected Item

 
 
Kris Rockwell
Guest
Posts: n/a
 
      04-11-2004
Hello (again),

I have gotten the dropdown list functionality to work through a few tricks
(probably not the most efficient, but it works) but I am not sure how to set
the default selected value. I have tried setting various values to represent
the default value with little success. Essentially I am looking to have the
first item in the list be the default selected item. I noticed in the
properties for a dtat grid you could set a default selected index
(DataGrid.SelectedIndex =). Is there a similiar property for the Dropdown
list that I am just not seeing?

DropDownList.SelectedIndex = 0 does not seem to work.

Regards,
Kris


 
Reply With Quote
 
 
 
 
Dan Brussee
Guest
Posts: n/a
 
      04-11-2004
What does not work about setting the list's selectedindex property?

On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
<(E-Mail Removed)> wrote:

>Hello (again),
>
>I have gotten the dropdown list functionality to work through a few tricks
>(probably not the most efficient, but it works) but I am not sure how to set
>the default selected value. I have tried setting various values to represent
>the default value with little success. Essentially I am looking to have the
>first item in the list be the default selected item. I noticed in the
>properties for a dtat grid you could set a default selected index
>(DataGrid.SelectedIndex =). Is there a similiar property for the Dropdown
>list that I am just not seeing?
>
>DropDownList.SelectedIndex = 0 does not seem to work.
>
>Regards,
>Kris
>


 
Reply With Quote
 
 
 
 
Kris Rockwell
Guest
Posts: n/a
 
      04-11-2004
Well, it seems although I set the property as follows:

DropDownList.SelectedIndex = 0

the selected value is not passed. If I try to get the value after setting
this I no return (although I do see the associsted text in the DDList).
However, if I select a different value and then select the initial value it
does retuen the index.

Regards,
Kris

"Dan Brussee" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> What does not work about setting the list's selectedindex property?
>
> On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
> <(E-Mail Removed)> wrote:
>
> >Hello (again),
> >
> >I have gotten the dropdown list functionality to work through a few

tricks
> >(probably not the most efficient, but it works) but I am not sure how to

set
> >the default selected value. I have tried setting various values to

represent
> >the default value with little success. Essentially I am looking to have

the
> >first item in the list be the default selected item. I noticed in the
> >properties for a dtat grid you could set a default selected index
> >(DataGrid.SelectedIndex =). Is there a similiar property for the Dropdown
> >list that I am just not seeing?
> >
> >DropDownList.SelectedIndex = 0 does not seem to work.
> >
> >Regards,
> >Kris
> >

>



 
Reply With Quote
 
Dan Brussee
Guest
Posts: n/a
 
      04-11-2004
Just being sure. You mention checking the value. The SelectedValue is
quite different than the SelectedIndex. Setting the SelectedIndex to 0
will select the first item in the dropdown list. It will have both a
Value and Text property as well.


On Sun, 11 Apr 2004 18:29:17 -0400, "Kris Rockwell"
<(E-Mail Removed)> wrote:

>Well, it seems although I set the property as follows:
>
>DropDownList.SelectedIndex = 0
>
>the selected value is not passed. If I try to get the value after setting
>this I no return (although I do see the associsted text in the DDList).
>However, if I select a different value and then select the initial value it
>does retuen the index.
>
>Regards,
>Kris
>
>"Dan Brussee" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed).. .
>> What does not work about setting the list's selectedindex property?
>>
>> On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
>> <(E-Mail Removed)> wrote:
>>
>> >Hello (again),
>> >
>> >I have gotten the dropdown list functionality to work through a few

>tricks
>> >(probably not the most efficient, but it works) but I am not sure how to

>set
>> >the default selected value. I have tried setting various values to

>represent
>> >the default value with little success. Essentially I am looking to have

>the
>> >first item in the list be the default selected item. I noticed in the
>> >properties for a dtat grid you could set a default selected index
>> >(DataGrid.SelectedIndex =). Is there a similiar property for the Dropdown
>> >list that I am just not seeing?
>> >
>> >DropDownList.SelectedIndex = 0 does not seem to work.
>> >
>> >Regards,
>> >Kris
>> >

>>

>


 
Reply With Quote
 
Kris Rockwell
Guest
Posts: n/a
 
      04-12-2004
Following what you have said, setting the code as follows should produce the
correct results.

...Omitted Connection, data adapter and Dataset info...

DropDownList.DataBind()
DropDownList.SelectedIndex = 0

In this instance the first item in the list should be selected by default
without any user interaction.

Is that a correct assumption?

Regards,
Kris

"Dan Brussee" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Just being sure. You mention checking the value. The SelectedValue is
> quite different than the SelectedIndex. Setting the SelectedIndex to 0
> will select the first item in the dropdown list. It will have both a
> Value and Text property as well.
>
>
> On Sun, 11 Apr 2004 18:29:17 -0400, "Kris Rockwell"
> <(E-Mail Removed)> wrote:
>
> >Well, it seems although I set the property as follows:
> >
> >DropDownList.SelectedIndex = 0
> >
> >the selected value is not passed. If I try to get the value after setting
> >this I no return (although I do see the associsted text in the DDList).
> >However, if I select a different value and then select the initial value

it
> >does retuen the index.
> >
> >Regards,
> >Kris
> >
> >"Dan Brussee" <(E-Mail Removed)> wrote in message
> >news:(E-Mail Removed).. .
> >> What does not work about setting the list's selectedindex property?
> >>
> >> On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
> >> <(E-Mail Removed)> wrote:
> >>
> >> >Hello (again),
> >> >
> >> >I have gotten the dropdown list functionality to work through a few

> >tricks
> >> >(probably not the most efficient, but it works) but I am not sure how

to
> >set
> >> >the default selected value. I have tried setting various values to

> >represent
> >> >the default value with little success. Essentially I am looking to

have
> >the
> >> >first item in the list be the default selected item. I noticed in the
> >> >properties for a dtat grid you could set a default selected index
> >> >(DataGrid.SelectedIndex =). Is there a similiar property for the

Dropdown
> >> >list that I am just not seeing?
> >> >
> >> >DropDownList.SelectedIndex = 0 does not seem to work.
> >> >
> >> >Regards,
> >> >Kris
> >> >
> >>

> >

>



 
Reply With Quote
 
Dan Brussee
Guest
Posts: n/a
 
      04-12-2004
Looks right to me.

On Sun, 11 Apr 2004 22:01:58 -0400, "Kris Rockwell"
<(E-Mail Removed)> wrote:

>Following what you have said, setting the code as follows should produce the
>correct results.
>
>..Omitted Connection, data adapter and Dataset info...
>
>DropDownList.DataBind()
>DropDownList.SelectedIndex = 0
>
>In this instance the first item in the list should be selected by default
>without any user interaction.
>
>Is that a correct assumption?
>
>Regards,
>Kris
>
>"Dan Brussee" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed).. .
>> Just being sure. You mention checking the value. The SelectedValue is
>> quite different than the SelectedIndex. Setting the SelectedIndex to 0
>> will select the first item in the dropdown list. It will have both a
>> Value and Text property as well.
>>
>>
>> On Sun, 11 Apr 2004 18:29:17 -0400, "Kris Rockwell"
>> <(E-Mail Removed)> wrote:
>>
>> >Well, it seems although I set the property as follows:
>> >
>> >DropDownList.SelectedIndex = 0
>> >
>> >the selected value is not passed. If I try to get the value after setting
>> >this I no return (although I do see the associsted text in the DDList).
>> >However, if I select a different value and then select the initial value

>it
>> >does retuen the index.
>> >
>> >Regards,
>> >Kris
>> >
>> >"Dan Brussee" <(E-Mail Removed)> wrote in message
>> >news:(E-Mail Removed).. .
>> >> What does not work about setting the list's selectedindex property?
>> >>
>> >> On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
>> >> <(E-Mail Removed)> wrote:
>> >>
>> >> >Hello (again),
>> >> >
>> >> >I have gotten the dropdown list functionality to work through a few
>> >tricks
>> >> >(probably not the most efficient, but it works) but I am not sure how

>to
>> >set
>> >> >the default selected value. I have tried setting various values to
>> >represent
>> >> >the default value with little success. Essentially I am looking to

>have
>> >the
>> >> >first item in the list be the default selected item. I noticed in the
>> >> >properties for a dtat grid you could set a default selected index
>> >> >(DataGrid.SelectedIndex =). Is there a similiar property for the

>Dropdown
>> >> >list that I am just not seeing?
>> >> >
>> >> >DropDownList.SelectedIndex = 0 does not seem to work.
>> >> >
>> >> >Regards,
>> >> >Kris
>> >> >
>> >>
>> >

>>

>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving the selected item from the dropdown list and storing it in a local variable yasodhai@gmail.com ASP .Net 6 03-08-2007 11:52 AM
POST url based upon item selected in dropdown list (sounds Simple) SA SA ASP General 5 10-19-2006 04:55 PM
list control and default to selected item? Moe Sizlak ASP .Net 1 07-07-2004 01:56 PM
dropdown list does not change selected item? SSP ASP .Net Web Controls 2 10-29-2003 08:31 PM
selected item and dropdown list/listbox rohith ASP .Net 3 08-29-2003 04:32 PM



Advertisments