Sorting numeric column and handling blank value

Sorting numeric column and handling blank value

bczm8703bczm8703 Posts: 16Questions: 5Answers: 0

I am integrating datatable with asp:gridview. the columns are dynamically created at runtime. when I tried to sort the numeric column, the blank data caused the whole column to be sorted as string.

my numeric column contains the following possible data

numeric column
1,234,567
234,567.89

213
-2,123,678

This question has an accepted answers - jump to answer

Answers

  • bczm8703bczm8703 Posts: 16Questions: 5Answers: 0
    edited December 2021

    i have did a test case

    refer to the count column

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    It's because that "numeric" column isn't numeric - it has HTML and values with a comma. You can use the numeric-comma sorting plugin, or use columns.render (with order) to strip those non-numeric characters/strings out.

    Colin

  • bczm8703bczm8703 Posts: 16Questions: 5Answers: 0

    but it will required me to know which column to set as numeric-comma type before runtime? my columns build and create only at runtime after getting the column type from the database

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    The other option is convert those non-numeric HTML fields for all fields - see here.

    The numbers are fine, I was mistaken there, your language settings were dealing with those correctly.

    Colin

Sign In or Register to comment.