1

Supposing i have the following values in a column in DataTable

120,00
200,00
201,00
12510,00

On sorting them in ASC ORDER i am always getting the 12510,00 on top and remaining sort perfectly fine. Any suggestion?

1 Answer 1

2

I assume it's a string column, you should fill it with the correct type. If that's not possible you can use decimal.Parse, for example:

tbl = tbl.AsEnumerable()
    .OrderBy(row => decimal.Parse(row.Field<string>("ColumnName")))
    .CopyToDataTable();

You need to add using System.Linq.

If you use a different decimal separator you can use decimal.Parse(row.Field<string>("ColumnName"), new CultureInfo("de-DE")).

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.