I have a listbox in which there are 100 items.
The items of the listbox is being populated from database.
Now after selecting an item, if I click any button(sending request to server), then though the selected listbox items is kept selected, but if I had selected say 70th Item, then this item gets hidden down into listbox as the listbox height is not enough to show all items. I want to show that selected item at the top of the listbox after I click the button.
Pls help

6 Years
Discussion Span
Last Post by Freon22

Thats weird behavior, I created a list box and added 100 items to it. I just use a default listbox. I then clicked a button control to do a postback and the selected item was still selected and was at the top. I then set my listbox height to 150px and it still worked ok.

So something else must be going on, I don't have a clued. Post some code maybe there is something in your css or LOL I don't know. But I will be watching this thread to see if someone else knows.

<asp:ListBox ID="ListBox1" runat="server" Height="150px"></asp:ListBox>

 if (!IsPostBack) 
            List<string> myListBox = new List<string>();
            for (int i = 0; i < 100; i++)
                myListBox.Add("Item " + i.ToString());
            ListBox1.DataSource = myListBox;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.