Saturday, March 24, 2012

Listbox

Hello,
i have a listbox in which i show a list of names,
ordered by the id that they are stored in a table.
I want that the listbox shows the list of names ordered
by the alphabetic order. How can i do that? Thanks.The answer is likely in the datasource you're binding to the list (if you're using data binding of course). The best solution in my opinion is to add the items to the list in the alfabetical order during the databinding. So, if you're binding a dataset to the list for example, make sure that the passed in dataset is ordered (e.g. by using the ORDER BY statement in SQL).

If you can give us some code extract from your sources that shows how you're filling the list, we'd be able to help you further in more detail (possibly you're not using a DataSet and then the solution will be somewhat different).
Hello,
Thanks bdesmet, i did what you tell me, and it works.
Now i have another question. In the listbox, when i click on one name i want to fire my edit sub. I don't want to use a button. Is there any property like the button's onclick?
What should i do to solve the problem?
You can set AutoPostBack="True" on the listbox, and then associate a subroutine with the OnSelectedIndexChanged event.

0 comments:

Post a Comment