Sort a listbox by last name asp.net VB

I have an asp.net app that has a listbox. It uses an sql datasource that populates with the full name column data. I have a user that wants the listbox to sort by the last name instead of the first name. Is that possible?
ICantSeeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anil GolamariCommented:
Hi,

You can sort the list on SQL end before loading it into listbox. Because Once loaded if you have full name as "Last Name + First Name" you should be able to sort it but I don't think we can do it other way round.

http://www.visual-basic-tutorials.com/SortListBox.htm

https://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.sort(v=vs.110).aspx


Thanks
0
David Johnson, CD, MVPOwnerCommented:
if the table is  only Name nvarchar(max) and not firstname nvarchar(max), lastname nvarchar(max) the answer is not really possible
0
ICantSeeAuthor Commented:
Basically what we are saying is if the data is entered into the table as lastname+firstname it will sort by the lastname. Otherwise this is difficult to do... correct?
0
David Johnson, CD, MVPOwnerCommented:
correct  we could create a temp table and try and split the first and last name but items such as initials, middle name, degrees and names with spaces in them
john doe, jane smith  easy to split
john doe, jane smith, george washington carver  more complex
john doe, jane smith, george washington carver, george c. Scott
john doe, jane smith, george washington carver, george c. Scott, John Paul LLD
john doe, jane smith, george washington carver, george c. Scott, John Paul LLD, Hansel Adolf von Richtofen

we have to cover all eventualities of a name.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ICantSeeAuthor Commented:
This is a new application so there is very little data in the table. I will instruct the users to enter the name as last name + first Name.

thank you for the help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.