Chiggins
Chiggins

Reputation: 8397

Sorting entries inside a ListView

I currently have a ListView that contains a listing of names, grabbing from an XML DataSouce. As of right now, everything works as it should, but the names are not in alphabetical order as I'd like them to be. I'd prefer not to use XSLT to recreate the XML file, so is there any other way to go about correctly sorting the ListView in alphabetical order?

Thanks!

Upvotes: 1

Views: 347

Answers (2)

Jvr
Jvr

Reputation: 97

Have you thought about using linq to sort the data? This will allow you to manipulate the data before passing it to the ListView.

Another example

-Jvr

Missed the native sorting, K.I.S.S !

Upvotes: 1

Steve
Steve

Reputation: 216243

The listview control has a Sort method.

public virtual void Sort(
    string sortExpression,
    SortDirection sortDirection
)

as from msdn 'Use the Sort method to programmatically sort the data that is displayed in the ListView control by using the specified sort expression and direction. '

details can be found here

Upvotes: 3

Related Questions