' I suggest you try to create a secondary datatable that transposes rows to
columns and columns to rows and then fill the values in by iterating .
'Pass the function the table to transpose as well as the primary key column
name i.e. InvoiceNumber
call the program like this:
Dim transdt as DataTable
transdt = TransposeDataTable(sometable,"id_firm")
datagrid1.datasource= transdt
Private Function TransposeDataTable(Byval CurrentTable as DataTable,Byval
PrimaryColumnName as String) as DataTable
Dim dt As New DataTable
Dim rows As Integer = 0
'add a column for the table values
Dim dcolvalue As New DataColumn("ColumnName")
With dcolvalue
..DataType = GetType(String)
..MaxLength = 255
End With
dt.Columns.Add(dcolvalue)
'loop through each row and create a column
For Each row As DataRow In CurrentTable.Rows
Dim dcol As New DataColumn(row(PrimaryColumnName).ToString) 'or add the
columnName as PrimaryKey
dt.Columns.Add(dcol)
rows += 1
Next
'iterate all the columns and create rows
For Each col As DataColumn In CurrentTable.Columns
Dim ColRow As DataRow
ColRow = dt.NewRow
ColRow.Item(0) = col.ColumnName
dt.Rows.Add(ColRow)
Next
'Now populate the information by iterating the rows over the columns
For i As Integer = 0 To CurrentTable.Rows.Count - 1
For k As Integer = 0 To CurrentTable.Columns.Count - 1
dt.Rows(k)(i + 1) = CurrentTable.Rows(i).Item(k)
Next
Next
return dt
End Sub