combobox problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • drishtik

    #1

    combobox problem

    hi
    i have a combobox which has some values loaded in it
    like (eg)
    a
    b
    c
    d


    i want to retrieve the value from the database (a, or b or c or d)
    and then select that item in the combo according ly

    foreach (DataRow dr in recs)
    {
    cmbType.Selecte dText = dr["descriptio n"].ToString(); //there is only one
    item here. is this the best way to iterate?
    }

    but this doesnt work
    dr["descriptio n"] has the correct value ie b . and i want to select b in
    the combo

    i tried combo.selectedv alue and selectedtext but they dont work.
    why and how do i solve this?

    cmbType.Selecte dText = dr["descriptio n"].ToString();


  • Dan Cimpoiesu

    #2
    Re: combobox problem

    Try
    cmbType.Selecte dValue=...

    Regards
    Dan Cimpoiesu

    "drishtik" <sheraze@hotmai l.com> wrote in message
    news:OWmu1CdfDH A.908@tk2msftng p13.phx.gbl...[color=blue]
    > hi
    > i have a combobox which has some values loaded in it
    > like (eg)
    > a
    > b
    > c
    > d
    >
    >
    > i want to retrieve the value from the database (a, or b or c or d)
    > and then select that item in the combo according ly
    >
    > foreach (DataRow dr in recs)
    > {
    > cmbType.Selecte dText = dr["descriptio n"].ToString(); //there is only one
    > item here. is this the best way to iterate?
    > }
    >
    > but this doesnt work
    > dr["descriptio n"] has the correct value ie b . and i want to select b in
    > the combo
    >
    > i tried combo.selectedv alue and selectedtext but they dont work.
    > why and how do i solve this?
    >
    > cmbType.Selecte dText = dr["descriptio n"].ToString();
    >
    >[/color]


    Comment

    • idog

      #3
      Re: combobox problem

      cmbType.Items.F indByText(dr["descriptio n"].ToString()).Se lected = True

      idog

      "Dan Cimpoiesu" <dancimpoiesu@g mx.net> wrote in message
      news:#uL1CkdfDH A.2248@TK2MSFTN GP09.phx.gbl...[color=blue]
      > Try
      > cmbType.Selecte dValue=...
      >
      > Regards
      > Dan Cimpoiesu
      >
      > "drishtik" <sheraze@hotmai l.com> wrote in message
      > news:OWmu1CdfDH A.908@tk2msftng p13.phx.gbl...[color=green]
      > > hi
      > > i have a combobox which has some values loaded in it
      > > like (eg)
      > > a
      > > b
      > > c
      > > d
      > >
      > >
      > > i want to retrieve the value from the database (a, or b or c or d)
      > > and then select that item in the combo according ly
      > >
      > > foreach (DataRow dr in recs)
      > > {
      > > cmbType.Selecte dText = dr["descriptio n"].ToString(); //there is only[/color][/color]
      one[color=blue][color=green]
      > > item here. is this the best way to iterate?
      > > }
      > >
      > > but this doesnt work
      > > dr["descriptio n"] has the correct value ie b . and i want to select b[/color][/color]
      in[color=blue][color=green]
      > > the combo
      > >
      > > i tried combo.selectedv alue and selectedtext but they dont work.
      > > why and how do i solve this?
      > >
      > > cmbType.Selecte dText = dr["descriptio n"].ToString();
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...