0

Hay guys i have a datatable of employees that have 6 column the first one is EmployeID, on page load i bind the data to the gridview and the result is this.

The screenshot

as you see on the screenshot the employe id start with
AG0
AG1
AG10
AG11
AG2
AG3
...

and i wanna sort them like.

AG0
AG1
AG2
AG3
AG4
AG5
AG10
AG11
...

Sorry about my english, and thanks in advance

3
  • Please add the code of your database query. Commented Apr 15, 2017 at 23:39
  • do you mean the stored procedure ??! Commented Apr 15, 2017 at 23:44
  • You need to remove AG from employeeid and convert it int and sort Commented Apr 16, 2017 at 4:27

1 Answer 1

0

There are some similar questions on SO. Here's one possible option, and you can explore other solutions by yourself (start with: 1, 2, 3):

var list = new List<string>() { "AG1", "AG10", "AG2"};
var ordered = list.Select(s => new { Original = s, Trimmed = s.TrimStart("AG".ToCharArray())})
                  .OrderBy(x => int.Parse(x.Trimmed))
                  .Select(x => x.Original)
                  .ToList();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.