Combo Box Junk

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

    #1

    Combo Box Junk

    I have a combo box that is databound to an ArrayList (IList to be more
    exact)

    I have a situation where if the user cancels a save I want the combo value
    to go back to blank. This should be SIMPLE.

    I have set the SelectedIndex to -1
    I have set the SelectedValue to any option under the sun
    I have set the every other known property to a value that would clear the
    currently selected option.

    All efforts only put the item above the currently selected item in the box.

    For instance, if I have 2 items A and B in my combo and the user chooses A,
    setting the SelectedIndex to -1 does the right thing--clears the combo box.
    If the user chooses B setting the SelectedIndex to -1 puts A in the box.

    Someone, please, enlighten me?


  • Bill Priess

    #2
    Re: Combo Box Junk

    By default, when you databind a dropdownlist, there is no "blank" value. All
    SelectedIndex = -1 does is tell it that there is not selected item. What you
    need to do is something like this:

    DropDownList.It ems.AddAt(0, new ListItem("","") );
    That should pop the blank item at the top of the dropdownlist.

    HTH,

    Bill P.
    "A" <agarrettbNOSPA M@hotmail.com> wrote in message
    news:OvsoA2srDH A.3196@TK2MSFTN GP11.phx.gbl...[color=blue]
    > I have a combo box that is databound to an ArrayList (IList to be more
    > exact)
    >
    > I have a situation where if the user cancels a save I want the combo value
    > to go back to blank. This should be SIMPLE.
    >
    > I have set the SelectedIndex to -1
    > I have set the SelectedValue to any option under the sun
    > I have set the every other known property to a value that would clear the
    > currently selected option.
    >
    > All efforts only put the item above the currently selected item in the[/color]
    box.[color=blue]
    >
    > For instance, if I have 2 items A and B in my combo and the user chooses[/color]
    A,[color=blue]
    > setting the SelectedIndex to -1 does the right thing--clears the combo[/color]
    box.[color=blue]
    > If the user chooses B setting the SelectedIndex to -1 puts A in the box.
    >
    > Someone, please, enlighten me?
    >
    >[/color]


    Comment

    • A

      #3
      Re: Combo Box Junk

      Yeah,

      I tried this when I was bound to a DataTable and it threw errors all over,
      but I will try again now that I am on an IList

      Thanks

      "Bill Priess" <no.spam@nospam .com> wrote in message
      news:OndpE8srDH A.536@tk2msftng p13.phx.gbl...[color=blue]
      > By default, when you databind a dropdownlist, there is no "blank" value.[/color]
      All[color=blue]
      > SelectedIndex = -1 does is tell it that there is not selected item. What[/color]
      you[color=blue]
      > need to do is something like this:
      >
      > DropDownList.It ems.AddAt(0, new ListItem("","") );
      > That should pop the blank item at the top of the dropdownlist.
      >
      > HTH,
      >
      > Bill P.
      > "A" <agarrettbNOSPA M@hotmail.com> wrote in message
      > news:OvsoA2srDH A.3196@TK2MSFTN GP11.phx.gbl...[color=green]
      > > I have a combo box that is databound to an ArrayList (IList to be more
      > > exact)
      > >
      > > I have a situation where if the user cancels a save I want the combo[/color][/color]
      value[color=blue][color=green]
      > > to go back to blank. This should be SIMPLE.
      > >
      > > I have set the SelectedIndex to -1
      > > I have set the SelectedValue to any option under the sun
      > > I have set the every other known property to a value that would clear[/color][/color]
      the[color=blue][color=green]
      > > currently selected option.
      > >
      > > All efforts only put the item above the currently selected item in the[/color]
      > box.[color=green]
      > >
      > > For instance, if I have 2 items A and B in my combo and the user chooses[/color]
      > A,[color=green]
      > > setting the SelectedIndex to -1 does the right thing--clears the combo[/color]
      > box.[color=green]
      > > If the user chooses B setting the SelectedIndex to -1 puts A in the box.
      > >
      > > Someone, please, enlighten me?
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...