C
Cameron Thomas
Hi There,
I am trying to loop throught the results of my query, my table has columns
that have colours and sizes with each colour have many sizes. Currently the
loop is just duplicating the colour size values for each colour. So for
instance if the colour has 2 of a particluar size the code writes that as
the value for all of the columns.
Couls someone help me out with the syntax please?
Cameron
desired result:
colour | size | size | size | size
colour | size | size | size | size
Dim dr As DataRow
Dim dc As DataColumn
Dim dc1 As DataColumn
For Each dr In ds.Tables(0).Rows
For Each dc In ds.Tables(0).Columns
If dc.ColumnName = "colour" Then
r = New TableRow
c = New TableCell
c.Controls.Add(New _
LiteralControl(dr("colour")))
c.VerticalAlign = VerticalAlign.Top
c.Style("background-color") = "lightblue"
r.Cells.Add(c)
For Each dc1 In ds.Tables(0).Columns
c = New TableCell
c.Controls.Add(New LiteralControl(dr("size")))
c.VerticalAlign = VerticalAlign.Top
r.Cells.Add(c)
Next
End If
Table2.Rows.Add(r)
Next
Next
I am trying to loop throught the results of my query, my table has columns
that have colours and sizes with each colour have many sizes. Currently the
loop is just duplicating the colour size values for each colour. So for
instance if the colour has 2 of a particluar size the code writes that as
the value for all of the columns.
Couls someone help me out with the syntax please?
Cameron
desired result:
colour | size | size | size | size
colour | size | size | size | size
Dim dr As DataRow
Dim dc As DataColumn
Dim dc1 As DataColumn
For Each dr In ds.Tables(0).Rows
For Each dc In ds.Tables(0).Columns
If dc.ColumnName = "colour" Then
r = New TableRow
c = New TableCell
c.Controls.Add(New _
LiteralControl(dr("colour")))
c.VerticalAlign = VerticalAlign.Top
c.Style("background-color") = "lightblue"
r.Cells.Add(c)
For Each dc1 In ds.Tables(0).Columns
c = New TableCell
c.Controls.Add(New LiteralControl(dr("size")))
c.VerticalAlign = VerticalAlign.Top
r.Cells.Add(c)
Next
End If
Table2.Rows.Add(r)
Next
Next