Reputation: 1
I have a .NET DataGrid below, it doesn't sort the column. For example, the sort is like
10 100 21 Even though DataFormatString="{0:N0} has been set, the sort still not work. PLEASE HELP.
<asp:DataGrid ID="StatusGrid" CssClass="StatusGrid" runat="server" AutoGenerateColumns="false"
UseAccessibleHeader="true" OnItemDataBound="StatusGrid_ItemDataBound" OnItemCommand="StatusGrid_ItemCommand">
<Columns>
ItemStyle-HorizontalAlign="Left" />
<asp:BoundColumn DataField="Rating" HeaderText="Performance Rating" ItemStyle-Width="110px"
ItemStyle-HorizontalAlign="Left" DataFormatString="{0:N0}"/>
</Columns>
Upvotes: 0
Views: 178
Reputation: 1032
This is probably a problem with the data type of the column. It's sorting as if it is a string instead of a number. You were on the right track with your DataFormatString idea but you need to either pass in the data to that column as an int, or implement some custom sorting described here:
http://msdn.microsoft.com/en-us/library/aa984282(v=vs.71).aspx
Upvotes: 1