Thursday, March 22, 2012

setting the listboxs window base to begin with specific index

When the web page is loaded, the listbox normally starts from index 0. For example, a listbox with window size 3 will show
index 0
index 1
index 2

However, right now I want the listbox's window base to begin with index 1,
index 1
index 2
index 3

What should I do?Hi you can do something like:

myList.SelectedIndex = 1;

hope this helps
I set the selectionmode to multiple.
I use your method. Even though the specific index is selected, the window base still starts with index 0.
Hi, why do u need to set the mode to multiple, leave it as single !!!
I am curious as to why you want to change from zero-based to one-based indexing in the listbox control?
I want the users to be able to select multiple items. For example, the user may want to query not only this year's data but also other years'.

I have two listboxes. When the user select a item in the first listbox, the corresponding item in the second listbox is automatically selected. I realize this by using postback. However, if the user selects the item at the end of the listbox, when posting back the web page, the listbox's window base will be pointing to the first item with index 0. The users will get confused if they can not see the item that they just select.

Thanks so much for your help. I hope to hear a solution from you soon.

0 comments:

Post a Comment