How to add column or value in data table?


I have a data like this :


After I join the data tables, the data are not in order berween 1-11 (random). So I tried to sort ascending and what I got is 1, 10, 11, then 2-9 (as seen in the picture).

I didn’t know what to do next. I tried to add data column and it’s not working because it’s added at the end of the last column.

Is there any way to do this 2 possible solution?

  1. Add column at the very beginning with the value.
  2. Build data table, and then put the value inside the column “No”


Use Sort data table activity to sort the table…


datatable dt =(From row In dt2.Select Order By Convert.ToInt32(row("Column1")) Select row).ToArray.CopyToDatatable()

  1. Use Insert column

Where you can insert the columns wherever you want with the column position…


you can numerically sort on the “No” column

How to sort numerically?

I tried sort ascending and I got this output :


please show us some details from your sorting implementation

In general we can use LINQ

Assign Activity
dtSorted =

(From d in dtJoin.AsEnumerable
Order by CInt(d("No").toString.Trim)
Select r = d).CopyToDataTable

This is how I’ve done it with Sort Data table

Try this:


Thank you @ppr @THIRU_NANI, both solutions are working !

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.