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

Make a value the default in a databound dropdown

P: n/a
I have a databound dropdown in my page. I want to make one of the
values the default value. Any ideas?

Just to explain further, I have also appended one item to the dropdown,
using the AppendDataBoundItems="True" property of the dropdown.
Unfortunately the item I have appended to the dropdown has become the
default value of the dropdown list which is not what I want.

Kind regards,

Steve.

Sep 7 '06 #1
Share this Question
Share on Google+
3 Replies

P: n/a
myDropDown.SelectedIndex =
myDropDown.Items.IndexOf(myDropDown.Items.FindByVa lue("yourDefaultValue"))

you can also use FindByText which uses the text, instead of the value.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Steve" <ba****@iranmania.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
>I have a databound dropdown in my page. I want to make one of the
values the default value. Any ideas?

Just to explain further, I have also appended one item to the dropdown,
using the AppendDataBoundItems="True" property of the dropdown.
Unfortunately the item I have appended to the dropdown has become the
default value of the dropdown list which is not what I want.

Kind regards,

Steve.

Sep 7 '06 #2

P: n/a
Thank you for this Karl.

Should I put this code in the page load event in page behind or can I
somehow put it as a parameter in between the dropdown tags in the page
itself.

Kind regads,

Steve
Karl Seguin [MVP] wrote:
myDropDown.SelectedIndex =
myDropDown.Items.IndexOf(myDropDown.Items.FindByVa lue("yourDefaultValue"))

you can also use FindByText which uses the text, instead of the value.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Steve" <ba****@iranmania.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
I have a databound dropdown in my page. I want to make one of the
values the default value. Any ideas?

Just to explain further, I have also appended one item to the dropdown,
using the AppendDataBoundItems="True" property of the dropdown.
Unfortunately the item I have appended to the dropdown has become the
default value of the dropdown list which is not what I want.

Kind regards,

Steve.
Sep 13 '06 #3

P: n/a
I'm pretty sure you're stuck doing it in codebehind.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Steve" <ba****@iranmania.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Thank you for this Karl.

Should I put this code in the page load event in page behind or can I
somehow put it as a parameter in between the dropdown tags in the page
itself.

Kind regads,

Steve
Karl Seguin [MVP] wrote:
>myDropDown.SelectedIndex =
myDropDown.Items.IndexOf(myDropDown.Items.FindByV alue("yourDefaultValue"))

you can also use FindByText which uses the text, instead of the value.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Steve" <ba****@iranmania.comwrote in message
news:11**********************@b28g2000cwb.googleg roups.com...
>I have a databound dropdown in my page. I want to make one of the
values the default value. Any ideas?

Just to explain further, I have also appended one item to the dropdown,
using the AppendDataBoundItems="True" property of the dropdown.
Unfortunately the item I have appended to the dropdown has become the
default value of the dropdown list which is not what I want.

Kind regards,

Steve.

Sep 14 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.