Combobox Id

Discussion in 'ASP .Net' started by Big E, Jun 11, 2004.

  1. Big E

    Big E Guest

    I'm using VB in ASP.Net with SQL Server 2000.

    I have a States Combobox that lists the State. The State has a StateId in
    table states. When I do updates to various tables from the form I would like
    to update the StateId not the StateName. I've looked at the datamember and
    datavalue stuff but don't understand it.

    Can anyone point me at a sample or some code they've used.

    Thanks.

    Big E
     
    Big E, Jun 11, 2004
    #1
    1. Advertising

  2. Big E

    Curt_C [MVP] Guest

    Combo box or DropDownList?
    should be
    this.DropDownList1.SelectedItem.Value
    or
    this.DropDownList1.SelectedItem.Text

    --
    Curt Christianson
    Owner/Lead Developer, DF-Software
    Site: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "Big E" <> wrote in message
    news:eQHGLW%...
    > I'm using VB in ASP.Net with SQL Server 2000.
    >
    > I have a States Combobox that lists the State. The State has a StateId in
    > table states. When I do updates to various tables from the form I would

    like
    > to update the StateId not the StateName. I've looked at the datamember and
    > datavalue stuff but don't understand it.
    >
    > Can anyone point me at a sample or some code they've used.
    >
    > Thanks.
    >
    > Big E
    >
    >
    >
     
    Curt_C [MVP], Jun 11, 2004
    #2
    1. Advertising

  3. Big E

    Big E Guest

    Your the best. Curt is the champ. It works.



    "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
    news:uTFS1m%...
    > Combo box or DropDownList?
    > should be
    > this.DropDownList1.SelectedItem.Value
    > or
    > this.DropDownList1.SelectedItem.Text
    >
    > --
    > Curt Christianson
    > Owner/Lead Developer, DF-Software
    > Site: http://www.Darkfalz.com
    > Blog: http://blog.Darkfalz.com
    >
    >
    > "Big E" <> wrote in message
    > news:eQHGLW%...
    > > I'm using VB in ASP.Net with SQL Server 2000.
    > >
    > > I have a States Combobox that lists the State. The State has a StateId

    in
    > > table states. When I do updates to various tables from the form I would

    > like
    > > to update the StateId not the StateName. I've looked at the datamember

    and
    > > datavalue stuff but don't understand it.
    > >
    > > Can anyone point me at a sample or some code they've used.
    > >
    > > Thanks.
    > >
    > > Big E
    > >
    > >
    > >

    >
    >
     
    Big E, Jun 11, 2004
    #3
  4. Big E

    Big E Guest

    Actually. When I try and retrieve the contents of the dropdownlist later the
    Value has the equivalents of the text. When I loaded it with data in a loop
    the value was 1 where the text was Alabama. Now later they both contain
    Alabama.

    Thanks.

    Big E


    TextBox1.Text = cboStateCompany.SelectedItem.Value

    TextBox2.Text = cboStateCompany.SelectedItem.Text





    "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
    news:uTFS1m%...
    > Combo box or DropDownList?
    > should be
    > this.DropDownList1.SelectedItem.Value
    > or
    > this.DropDownList1.SelectedItem.Text
    >
    > --
    > Curt Christianson
    > Owner/Lead Developer, DF-Software
    > Site: http://www.Darkfalz.com
    > Blog: http://blog.Darkfalz.com
    >
    >
    > "Big E" <> wrote in message
    > news:eQHGLW%...
    > > I'm using VB in ASP.Net with SQL Server 2000.
    > >
    > > I have a States Combobox that lists the State. The State has a StateId

    in
    > > table states. When I do updates to various tables from the form I would

    > like
    > > to update the StateId not the StateName. I've looked at the datamember

    and
    > > datavalue stuff but don't understand it.
    > >
    > > Can anyone point me at a sample or some code they've used.
    > >
    > > Thanks.
    > >
    > > Big E
    > >
    > >
    > >

    >
    >
     
    Big E, Jun 11, 2004
    #4
  5. Hey Big E,
    the DataTextField and DataValueField properties of the dropdownlist
    are actually pretty simple. In your states table, I am assuming you
    have 2 rows. The stateID and the stateName. At design time, you want
    to make the DataTextField of your dropdown "stateName", and your
    DataValueField "stateID". When the form submits, you can simply look
    at the value of the dropdownlist, and it should be the stateID. Hope
    this helps!
     
    Justin Beckwith, Jun 12, 2004
    #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. Al Wilkerson

    Populating a ComboBox in C#

    Al Wilkerson, Nov 14, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    134,107
    Waqas
    Aug 22, 2012
  2. dbuchanan
    Replies:
    6
    Views:
    4,963
    dbuchanan
    Feb 2, 2006
  3. dbuchanan
    Replies:
    3
    Views:
    706
    Cor Ligthert [MVP]
    Feb 1, 2006
  4. Tamir Berger

    ComboBox

    Tamir Berger, Jun 25, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    1,912
    Tom Johnson
    Jun 25, 2003
  5. Replies:
    5
    Views:
    490
    Roedy Green
    Oct 11, 2012
Loading...

Share This Page