Monday, March 26, 2012

Newbie combo question

Hi - I've loaded the values into a combo box at runtime, but can't see how I
set the combo to a certain value when the page loads. (The value will change
depending on other variables when the page loads.)

Thanks

NickArrest me if I'm wrong, but from what I know there is no ComboBox available
in ASP.NET
Are you using a Custom Control?

Shawn

"Nick" <Nick@.NTWorks.no.spam.fsnet.co.uk> wrote in message
news:eNGWFRV$EHA.3840@.tk2msftngp13.phx.gbl...
> Hi - I've loaded the values into a combo box at runtime, but can't see how
I
> set the combo to a certain value when the page loads. (The value will
change
> depending on other variables when the page loads.)
> Thanks
> Nick
I mean this one:
System.Web.UI.WebControls.DropDownList

Nick

"Shawn" <bossman100@.hotmail.com> wrote in message
news:ubG7qYV$EHA.1904@.TK2MSFTNGP14.phx.gbl...
> Arrest me if I'm wrong, but from what I know there is no ComboBox
> available
> in ASP.NET
> Are you using a Custom Control?
> Shawn
>
> "Nick" <Nick@.NTWorks.no.spam.fsnet.co.uk> wrote in message
> news:eNGWFRV$EHA.3840@.tk2msftngp13.phx.gbl...
>> Hi - I've loaded the values into a combo box at runtime, but can't see
>> how
> I
>> set the combo to a certain value when the page loads. (The value will
> change
>> depending on other variables when the page loads.)
>>
>> Thanks
>>
>> Nick
>>
>>
If you are using .NET Framework 1.1 then you can use:
myDropDownList.SelectedValue

In .NET Framework 1.0 you can use SelectedIndex and then do a search for
your value, like this:
myDropDownList.SelectedIndex =
myDropDownList.Items.IndexOf(myDropDownList.Items. FindByValue(myValue))
or
myDropDownList.SelectedIndex =
myDropDownList.Items.IndexOf(myDropDownList.Items. FindByText(myText))

Hope this helps,
Shawn

"Nick" <Nick@.NTWorks.no.spam.fsnet.co.uk> wrote in message
news:uwNcZdV$EHA.1188@.tk2msftngp13.phx.gbl...
> I mean this one:
> System.Web.UI.WebControls.DropDownList
> Nick
> "Shawn" <bossman100@.hotmail.com> wrote in message
> news:ubG7qYV$EHA.1904@.TK2MSFTNGP14.phx.gbl...
> > Arrest me if I'm wrong, but from what I know there is no ComboBox
> > available
> > in ASP.NET
> > Are you using a Custom Control?
> > Shawn
> > "Nick" <Nick@.NTWorks.no.spam.fsnet.co.uk> wrote in message
> > news:eNGWFRV$EHA.3840@.tk2msftngp13.phx.gbl...
> >> Hi - I've loaded the values into a combo box at runtime, but can't see
> >> how
> > I
> >> set the combo to a certain value when the page loads. (The value will
> > change
> >> depending on other variables when the page loads.)
> >>
> >> Thanks
> >>
> >> Nick
> >>
> >>

0 comments:

Post a Comment