I have a GridView with a row number (Container.DataItemIndex) column in ASP.NET (1,2,3,4, ...)
I added it in GridView by following code :
<asp:TemplateField HeaderText="#" SortExpression="#">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
I wanna sort the GridView by this column.
I mean
ASC : 1,2,3,4, ...
DESC : n,n-1, ... , 4,3,2,1
How can I do it ?
Edit:
I did it by this way http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.sorting.aspx but it sorts # column like 1,11,12,13,...,2,21,22,...
I want to sort # column 1,2,3,...,11,12,13,...