S
Stimp
This is a question I'm carrying over from a previous one I made today
since I've simplified where the problem is...
I have a datatable, tblFeatures, which has around 30 columns (one for
each 'feature').
I also have between 1 and 3 rows of data (one for each 'vehicle').
I want to transpose this table so that I ouput the rows horizontally
and the columns vertically.
I'm looping through the datatable and manually creating the HTML as I
progress.. e.g.
Dim colFeatures As DataColumn
Dim rowFeatures As DataRow
Dim sOutputFeatures As System.Text.StringBuilder = New
System.Text.StringBuilder
For Each colFeatures In tblFeatures.Columns
sOutputFeatures.Append("<TR>")
sOutputFeatures.Append("<TD>" & colFeatures.ColumnName & "</TD>")
For Each rowFeatures In tblFeatures.Rows
sOutputFeatures.Append("<TD>" & rowFeatures(colFeatures) & "</TD>")
Next
sOutputFeatures.Append("</TR>")
Next
Response.Write sOutputFeatures.ToString()
but for some reason .. this is outputting 29 empty <TD></TD> for each
row value that it outputs.
I think I may be using the wrong syntax around the:
'For Each rowFeatures In tblFeatures.Rows' for loop
Does anyone know the proper syntax I should be using here?
Thanks in advance!
Peter
since I've simplified where the problem is...
I have a datatable, tblFeatures, which has around 30 columns (one for
each 'feature').
I also have between 1 and 3 rows of data (one for each 'vehicle').
I want to transpose this table so that I ouput the rows horizontally
and the columns vertically.
I'm looping through the datatable and manually creating the HTML as I
progress.. e.g.
Dim colFeatures As DataColumn
Dim rowFeatures As DataRow
Dim sOutputFeatures As System.Text.StringBuilder = New
System.Text.StringBuilder
For Each colFeatures In tblFeatures.Columns
sOutputFeatures.Append("<TR>")
sOutputFeatures.Append("<TD>" & colFeatures.ColumnName & "</TD>")
For Each rowFeatures In tblFeatures.Rows
sOutputFeatures.Append("<TD>" & rowFeatures(colFeatures) & "</TD>")
Next
sOutputFeatures.Append("</TR>")
Next
Response.Write sOutputFeatures.ToString()
but for some reason .. this is outputting 29 empty <TD></TD> for each
row value that it outputs.
I think I may be using the wrong syntax around the:
'For Each rowFeatures In tblFeatures.Rows' for loop
Does anyone know the proper syntax I should be using here?
Thanks in advance!
Peter