Blealuelinura
New Member
Here's the GridView:\[code\]<asp:GridView ID="MyGridView" runat="server" AllowPaging="true" AllowSorting="true" OnPageIndexChanging="MyGridView_PageIndexChanging" OnSorting="MyGridView_Sorting"> <Columns> <asp:TemplateField HeaderText="ID" SortExpression="Id"> <ItemTemplate> <asp:Label ID="idLabel" runat="server" Text='<%# Bind("Id") %>' /> </ItemTemplate> </asp:TemplateField> </Columns></asp:GridView>\[/code\]Here, the Id column is a string consisting always of the letter "T" followed by a number, i.e. "T1" or "T597" The other columns are fairly ordinary name and description String fields.I need this Id column to sort as though the Id were numeric, ignoring the letter in front. But because it is there, it is being treated as a String and sorting as such: T1, T10, T100, T2, T231, T34, ...So what I thought would be possible is:\[code\]protected void MyGridView_Sorting(object sender, GridViewSortEventArgs e){ if (e.SortExpression.Equals("Id") { // Special sorting code } else { // Normal sorting code }}\[/code\]Where the "normal" sorting code follows the common pattern of converting the \[code\]DataSource\[/code\] to \[code\]DataView\[/code\] and setting \[code\]DataView.Sort = e.SortExpression\[/code\] etc, for example: allow sorting by column gridviewSo what do I do for the "special" sorting code?