468,110 Members | 1,867 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,110 developers. It's quick & easy.

DropDown List Default Selected Item

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
Nov 18 '05 #1
5 10384
What does not work about setting the list's selectedindex property?

On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
<kr***************************@hybrid-learning.com> 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


Nov 18 '05 #2
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" <db******@nc.rr.com> wrote in message
news:m4********************************@4ax.com...
What does not work about setting the list's selectedindex property?

On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
<kr***************************@hybrid-learning.com> 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 setthe default selected value. I have tried setting various values to representthe default value with little success. Essentially I am looking to have thefirst 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

Nov 18 '05 #3
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"
<kr***************************@hybrid-learning.com> 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" <db******@nc.rr.com> wrote in message
news:m4********************************@4ax.com.. .
What does not work about setting the list's selectedindex property?

On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
<kr***************************@hybrid-learning.com> wrote:
>Hello (again),
>
>I have gotten the dropdown list functionality to work through a fewtricks >(probably not the most efficient, but it works) but I am not sure how toset >the default selected value. I have tried setting various values torepresent >the default value with little success. Essentially I am looking to havethe >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
>


Nov 18 '05 #4
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" <db******@nc.rr.com> wrote in message
news:f8********************************@4ax.com...
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"
<kr***************************@hybrid-learning.com> 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 itdoes retuen the index.

Regards,
Kris

"Dan Brussee" <db******@nc.rr.com> wrote in message
news:m4********************************@4ax.com.. .
What does not work about setting the list's selectedindex property?

On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
<kr***************************@hybrid-learning.com> 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
havethe
>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
>

Nov 18 '05 #5
Looks right to me.

On Sun, 11 Apr 2004 22:01:58 -0400, "Kris Rockwell"
<kr***************************@hybrid-learning.com> 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" <db******@nc.rr.com> wrote in message
news:f8********************************@4ax.com.. .
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"
<kr***************************@hybrid-learning.com> 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 valueit >does retuen the index.
>
>Regards,
>Kris
>
>"Dan Brussee" <db******@nc.rr.com> wrote in message
>news:m4********************************@4ax.com.. .
>> What does not work about setting the list's selectedindex property?
>>
>> On Sun, 11 Apr 2004 14:25:13 -0400, "Kris Rockwell"
>> <kr***************************@hybrid-learning.com> 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 howto >set
>> >the default selected value. I have tried setting various values to
>represent
>> >the default value with little success. Essentially I am looking tohave >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 theDropdown >> >list that I am just not seeing?
>> >
>> >DropDownList.SelectedIndex = 0 does not seem to work.
>> >
>> >Regards,
>> >Kris
>> >
>>
>


Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by passion_to_be_free | last post: by
5 posts views Thread by Kris Rockwell | last post: by
2 posts views Thread by Mike Collins | last post: by
5 posts views Thread by =?Utf-8?B?Y2hlY2tyYWlzZXJAY29tbXVuaXR5Lm5vc3BhbQ== | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.