November 13th, 2003, 03:17 PM
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 ?
November 13th, 2003, 03:29 PM
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.
November 14th, 2003, 01:24 PM
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.
Hope this will help you.
November 17th, 2003, 09:04 AM
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.