#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11

    Question How to let a Selected item in a ComboBox Stay Selected ???


    Here is my problem

    I have a combobox, and I have 3 other buttons. Add, Modify and Delete

    The user select an item in the combobox then press one of the 3 buttons. The program do something. And then the user can either select a new item or press another button. But when he press another button, it's still need to work with the item that the user previously selected in the combobox. But when I do combobox.selectedindex then it's return me -1

    That's mean the user need to choose again the item he want. I don't want that. I don't understand why the combox lose his selected item after a while.

    I tryed many things that I tought might work but I haven't found anything yet that work !
    I tryed to use the selecteditem, selectedtext etc... but that doesn't do anything. There is kinda no property that I see I could may be use. it's weird !

    anybody ever got something like that ? how you got out of it ?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11
    a better exemple might be this one.

    When I modify an item in the combobox. Then I reload the combobox with all the items and all the one that got modifed change his name. and I do a combobox.text = mynewitemmodified.text
    but if the person press again the button Modify, then it's like if no item is selected soo seletecindex have -1. And then it doesn't work

    how can I code the combobox to have something selected. I don't know.

    I hope that explain better my problem.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    India
    Posts
    4
    Rep Power
    0

    Thumbs up


    This is something regularly occurs for every ASP.Net page. The event that actually make your selecteditem unavailable is the page load. You need to check the Page.isPostback in the page load to track this down.

    Usage
    =====
    If postback
    Do Nothing
    End if

    Hope this will help you.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11
    Originally posted by bibinisacmohan
    This is something regularly occurs for every ASP.Net page. The event that actually make your selecteditem unavailable is the page load. You need to check the Page.isPostback in the page load to track this down.

    Usage
    =====
    If postback
    Do Nothing
    End if

    Hope this will help you.
    i forgot to say I am in a .Net application and not in an asp.net cause yeah if not your things would have worked .

    for the moment, I just let it go and I force the user to select it, but I hate to force a user to do anything, it's not something they like and it always result in problems from them lol.

IMN logo majestic logo threadwatch logo seochat tools logo