Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8266543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:11:51+00:00 2026-06-08T05:11:51+00:00

I have one DataTable called DTStage. It has two columns such as SeqNbr and

  • 0

I have one DataTable called “DTStage”. It has two columns such as “SeqNbr” and “StageID”.

I want to sort the datatable based on “SeqNbr”.

The DataTable has the following records:

     SeqNbr         StageID
    --------      -----------
       0               1
       1               2
       2               3
       3               4
       4               5
       5               6
       6               7
       7               8
       8               9
       9               10
       10              11
       11              12
       12              13
       13              14
       14              15
       15              16
       16              17
       18              18
       17              19

I have used two methods to sort this datatable, they are as follows:

 DTStage = new DataView(DTStage, "", "SeqNbr asc", DataViewRowState.CurrentRows).ToTable();

                     &

 DataView dv = DTStage.DefaultView;
 dv.Sort = DTStage.Columns["SeqNbr"] + " asc";
 DTStage = dv.ToTable();

But both gives the same result as follows:

     SeqNbr         StageID
    --------      -----------
        0               1
        1               2
       10               11
       11               12
       12               13
       13               14
       14               15
       15               16
       16               17
       17               19
       18               18
        2               3
        3               4
        4               5
        5               6
        6               7
        7               8
        8               9
        9               10

Why this is not working properly? How to solve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T05:11:53+00:00Added an answer on June 8, 2026 at 5:11 am

    it looks like your SeqNbr column is of type string so it gets sorted by characters and not as numbers. if those are numbers (I assume integers) why don’t you have the column type as int in the DataTable?

    This should help you: Sort string items in a datatable as int using c#

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 datatables in a dataset. One table has a list called CostTypes.
I have one datatable. In that table I have columns named [Total Day], [Present
I have one sqlserver 2008 r2 datatable, it has one column autoId int identity(1,1),
I have a dataset with one datatable. Now I want to set a filter
I have a table called Shoppings in my SQL db. This one has a
I have One DataTable may have more Columns. But NetAmount, TotalAmount, Destination are the
I have a table called SharedNumber , which has only one field - an
I have acefaces datatable with file names, one on row and I'm trying to
I have two datatables. One is to display names. Another contains three <h:selectOneMenu> .
I have a data table. Each row of the table has a commandButton called

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.