Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > specifying datavaluefield in ddlb

Reply
Thread Tools

specifying datavaluefield in ddlb

 
 
=?Utf-8?B?U2FuZHBvaW50R3V5?=
Guest
Posts: n/a
 
      09-27-2007
I have a dropdown of states that is populated from a table, that looks like
ddlb.DataValueField="StateCode" // ex: FL
ddlb.DataTextField="StateDescription" // ex: Florida

If I want to set the initial value I can use
ddlb.SelectedValue="Florida"
In other words, SelectedValue is the DataTextField

How do I set the initial value to the DataValueField?
ddlb.SelectedValue="FL" doesnt work (or is it just me?)

Thanks, Mark
 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      09-27-2007
you can do

dd.SelectedText = "FL";

is the value for Florida acutally FL?

Mike


"SandpointGuy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a dropdown of states that is populated from a table, that looks like
> ddlb.DataValueField="StateCode" // ex: FL
> ddlb.DataTextField="StateDescription" // ex: Florida
>
> If I want to set the initial value I can use
> ddlb.SelectedValue="Florida"
> In other words, SelectedValue is the DataTextField
>
> How do I set the initial value to the DataValueField?
> ddlb.SelectedValue="FL" doesnt work (or is it just me?)
>
> Thanks, Mark



 
Reply With Quote
 
 
 
 
=?Utf-8?B?U2FuZHBvaW50R3V5?=
Guest
Posts: n/a
 
      09-27-2007
There is no SelectedText property for the drop down list box.

"Mike" wrote:

> you can do
>
> dd.SelectedText = "FL";
>
> is the value for Florida acutally FL?
>
> Mike
>
>
> "SandpointGuy" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I have a dropdown of states that is populated from a table, that looks like
> > ddlb.DataValueField="StateCode" // ex: FL
> > ddlb.DataTextField="StateDescription" // ex: Florida
> >
> > If I want to set the initial value I can use
> > ddlb.SelectedValue="Florida"
> > In other words, SelectedValue is the DataTextField
> >
> > How do I set the initial value to the DataValueField?
> > ddlb.SelectedValue="FL" doesnt work (or is it just me?)
> >
> > Thanks, Mark

>
>
>

 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      09-27-2007
try this:
dd.SelectedItem.Text = "FL";

or if you know the index number of Fl you can do

dd.SelectedIndex = 5 (or whatever FL is)

Mike


"SandpointGuy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> There is no SelectedText property for the drop down list box.
>
> "Mike" wrote:
>
>> you can do
>>
>> dd.SelectedText = "FL";
>>
>> is the value for Florida acutally FL?
>>
>> Mike
>>
>>
>> "SandpointGuy" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> >I have a dropdown of states that is populated from a table, that looks
>> >like
>> > ddlb.DataValueField="StateCode" // ex: FL
>> > ddlb.DataTextField="StateDescription" // ex: Florida
>> >
>> > If I want to set the initial value I can use
>> > ddlb.SelectedValue="Florida"
>> > In other words, SelectedValue is the DataTextField
>> >
>> > How do I set the initial value to the DataValueField?
>> > ddlb.SelectedValue="FL" doesnt work (or is it just me?)
>> >
>> > Thanks, Mark

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?U2FuZHBvaW50R3V5?=
Guest
Posts: n/a
 
      09-27-2007

Actually, SelectedItem.Value is closer to what I want. But it adds a new
entry at the top, rather than selecting the existing value of "FL"

In other words, I get :
<option value="FL" selected="selected" value="FL">Alabama
<option value="AL">Alabama
.... other states
<option value="FL">Florida

And what I want is:
<option value="FL" selected="selected">Florida
<option value="AL">Alabama
.... other states


"Mike" wrote:

> try this:
> dd.SelectedItem.Text = "FL";
>
> or if you know the index number of Fl you can do
>
> dd.SelectedIndex = 5 (or whatever FL is)
>
> Mike
>
>
> "SandpointGuy" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > There is no SelectedText property for the drop down list box.
> >
> > "Mike" wrote:
> >
> >> you can do
> >>
> >> dd.SelectedText = "FL";
> >>
> >> is the value for Florida acutally FL?
> >>
> >> Mike
> >>
> >>
> >> "SandpointGuy" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> >I have a dropdown of states that is populated from a table, that looks
> >> >like
> >> > ddlb.DataValueField="StateCode" // ex: FL
> >> > ddlb.DataTextField="StateDescription" // ex: Florida
> >> >
> >> > If I want to set the initial value I can use
> >> > ddlb.SelectedValue="Florida"
> >> > In other words, SelectedValue is the DataTextField
> >> >
> >> > How do I set the initial value to the DataValueField?
> >> > ddlb.SelectedValue="FL" doesnt work (or is it just me?)
> >> >
> >> > Thanks, Mark
> >>
> >>
> >>

>
>
>

 
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
How to Fill DDLB with 3000+ data .?? MonikaJethi2@gmail.com ASP .Net Web Controls 1 01-23-2008 11:46 AM
ddlb clearing =?Utf-8?B?TWFya0F1cml0?= ASP .Net 2 06-22-2006 03:12 PM
Concatenating Multiple Values for DataValueField =?Utf-8?B?UkY=?= ASP .Net 6 12-03-2004 05:15 PM
DropdownList, DataValueField, DataTextField and Custom Collections.. Parodi Development ASP .Net 0 09-10-2004 06:29 PM
differring option and value in ddlb Mark ASP .Net Web Controls 1 10-30-2003 04:38 PM



Advertisments