Rather than sorting my listboxes by the Text property of the ListBoxItems, I want to use the Value property.
I understand that I'm going to have to do that server-side and I have no problem with that it's just that the following seems a lot of work...
And if I want to sort by an attribute I would have to create a comparer for each one.
It would be nice to be just able to write something like ...
Or have I missed something?
--
Stuart
I understand that I'm going to have to do that server-side and I have no problem with that it's just that the following seems a lot of work...
public
partial
class
HierarchyMaintenance : System.Web.UI.Page
{
protected
void
ListBox_Transferred(
object
sender, RadListBoxTransferredEventArgs e)
{
e.DestinationListBox.Items.Sort(
new
ListBoxValueComparer());
}
public
class
ListBoxValueComparer : System.Collections.IComparer
{
int
System.Collections.IComparer.Compare(Object x, Object y)
{
string
xValue = (x
as
RadListBoxItem).Value;
string
yValue = (y
as
RadListBoxItem).Value;
return
Comparer.DefaultInvariant.Compare(xValue, yValue);
}
}
}
And if I want to sort by an attribute I would have to create a comparer for each one.
It would be nice to be just able to write something like ...
e.DestinationListBox.Items =
e.DestinationListBox.Items.OrderBy(i=>i.Attributes[
"MyAttribute"
]);
Or have I missed something?
--
Stuart