specifying datavaluefield in ddlb

Discussion in 'ASP .Net' started by =?Utf-8?B?U2FuZHBvaW50R3V5?=, Sep 27, 2007.

  1. 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
     
    =?Utf-8?B?U2FuZHBvaW50R3V5?=, Sep 27, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?U2FuZHBvaW50R3V5?=

    Mike Guest

    you can do

    dd.SelectedText = "FL";

    is the value for Florida acutally FL?

    Mike


    "SandpointGuy" <> wrote in message
    news:...
    >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
     
    Mike, Sep 27, 2007
    #2
    1. Advertising

  3. 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" <> wrote in message
    > news:...
    > >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

    >
    >
    >
     
    =?Utf-8?B?U2FuZHBvaW50R3V5?=, Sep 27, 2007
    #3
  4. =?Utf-8?B?U2FuZHBvaW50R3V5?=

    Mike Guest

    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" <> wrote in message
    news:...
    > 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" <> wrote in message
    >> news:...
    >> >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

    >>
    >>
    >>
     
    Mike, Sep 27, 2007
    #4
  5. 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" <> wrote in message
    > news:...
    > > 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" <> wrote in message
    > >> news:...
    > >> >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
    > >>
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?U2FuZHBvaW50R3V5?=, Sep 27, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Parodi Development
    Replies:
    0
    Views:
    3,696
    Parodi Development
    Sep 10, 2004
  2. =?Utf-8?B?UkY=?=

    Concatenating Multiple Values for DataValueField

    =?Utf-8?B?UkY=?=, Dec 2, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    7,420
    Marina
    Dec 3, 2004
  3. =?Utf-8?B?TWFya0F1cml0?=

    ddlb clearing

    =?Utf-8?B?TWFya0F1cml0?=, Jun 22, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    374
    =?Utf-8?B?TWFya0F1cml0?=
    Jun 22, 2006
  4. Mark

    differring option and value in ddlb

    Mark, Oct 30, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    142
  5. How to Fill DDLB with 3000+ data .??

    , Jan 22, 2008, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    150
    PJ on Development
    Jan 23, 2008
Loading...

Share This Page