I have a problem when sorting RadGrid which has Scandinavian characters (åäöÅÄÖ).
E.g. Columns below having following data are not handled correctly (sample case):
[Driver] <-- Data not sorted properly -->
Räikkönen
Raikkonen
Åslund
Aslund
Rows Åslund and Räikkönen shuld be the last ones.
So, how could I tell RadGrid that it should support UTF-8 (or something else???) that sorting would work?
Below is my aspx and cs codesnippets
telerik:RadGrid ID="RadGridPersons" runat="server"
AutoGenerateColumns="False" AllowFilteringByColumn="false" AllowSorting="True"
SortingSettings-EnableSkinSortStyles="true" Width="80%" Visible="false"
OnSortCommand="RadGridPersons_SortCommand" onitemdatabound="RadGridPersons_ItemDataBound">
<MasterTableView CellSpacing="-1" TableLayout="Fixed" Width="100%"
AllowNaturalSort="false" AllowMultiColumnSorting="false">
<SortExpressions>
<telerik:GridSortExpression FieldName="LastName" SortOrder="Ascending" />
</SortExpressions>
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="CustomerId"
HeaderText='<%$Resources:Customers, PersonCustomerSearchResultHeader_CustomerNumber%>'
SortExpression="CustomerId" UniqueName="CustomerId" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridHyperLinkColumn DataTextField="LastName"
HeaderText='<%$Resources:Customers, PersonCustomerSearchResultHeader_LastName%>'
SortExpression="LastName" UniqueName="LastName" DataNavigateUrlFields="CustomerId"
DataNavigateUrlFormatString="PersonCustomer.aspx?CustomerId={0}" Visible="true"
HeaderStyle-Width="90" HeaderStyle-Wrap="true" ItemStyle-Font-Italic="true"
ItemStyle-Width="90" ItemStyle-Wrap="false">
</telerik:GridHyperLinkColumn>
protected void RadGridPersons_SortCommand(object source, Telerik.Web.UI.GridSortCommandEventArgs e) |
{ |
GridDataItemCollection Coll = RadGridPersons.MasterTableView.Items; |
var Items = from GridDataItem item in Coll |
orderby e.CommandSource ascending |
select new |
{ |
CustomerId = item["CustomerId"].Text.ToString(), |
LastName = (item["LastName"].Controls[0] as HyperLink).Text.ToString(), |
ForeNames = item["ForeNames"].Text.ToString(), |
Street = item["Street"].Text.ToString(), |
PostalCode = item["PostalCode"].Text.ToString(), |
City = item["City"].Text.ToString(), |
SocialSecurityId = item["SocialSecurityId"].Text.ToString(), |
StatusKey = item["StatusKey"].Text.ToString(), |
}; |
RadGridPersons.DataSource = |
(e.NewSortOrder == GridSortOrder.Ascending) ? Items : Items.OrderByDescending(x => x.LastName); |
RadGridPersons.DataBind(); |
} |
Thanks,
Michael