Transpose Rows to columns in datatable

  • Thread starter Thread starter Chris Smith
  • Start date Start date
C

Chris Smith

Experience Posters,

Sorry if this is not the right group to post this question.

He is my issue;

Is there a way without the use of 3rd party controls, to transpose the rows
of a datatable to columns of the datatable?

Any help would be great.

Much Thanks,

Chris Smith
 
Hi Chris,

It is very simple call the rows col and the col rows

Something like this, (goes for every table)

I hope this helps?

Cor
\\\
Dim dtnew As New DataTable
For i As Integer = 0 To dt.Rows.Count - 1
dtnew.Columns.Add(i.ToString)
Next
For i As Integer = 0 To dt.Columns.Count - 1
Dim dr As DataRow = dtnew.NewRow
dtnew.Rows.Add(dr)
Next
For i As Integer = 0 To dt.Rows.Count - 1
For j As Integer = 0 To dt.Columns.Count - 1
dtnew.Rows(i).item(j) = _
dt.Rows(j).Item(i).tostring
Next
Next
///
 
Back
Top