Currently, the layout of my table looks like this:
<tr>
<td> Field1 </td>
<td> Field2 </td>
<td> Field3 </td>
<td> Field4 </td>
<td> Field5 </td>
</tr>
<tr>
<td> anothefield1 </td>
<td> anothefield2 </td>
<td> anothefield3 </td>
<td> anothefield1 </td>
<td> anothefield1 </td>
</tr>
I want to dynamically add a CSS class in every td per column. It should look like this:
<tr>
<td class = '1'> Field1 </td>
<td class = '2'> Field2 </td>
<td class = '3'> Field3 </td>
<td class = '4'> Field4 </td>
<td class = '5'> Field5 </td>
</tr>
<tr>
<td class = '1'> anothefield1 </td>
<td class = '2'> anothefield2 </td>
<td class = '3'> anothefield3 </td>
<td class = '4'> anothefield4 </td>
<td class = '5'> anothefield5 </td>
</tr>
This pattern should continue for each row.
To achieve this layout, I have written some code so far:
Dim dv As New DataView(ds.Tables(0))
Dim dvfilter As DataTable = dv.ToTable(True, {"date"})
Dim dt2 As New DataTable
For Each dtrow As DataRow In dvfilter.Rows
dv.RowFilter = "Total_Load < Potential_Load"
dt2 = dv.ToTable(False, "Field1", "Field2", "Field3", "Field4", "Field5"})
Next
Dim builder As New StringBuilder
builder.Append("<!DOCTYPE html><html>")
builder.Append("<head>")
builder.Append("</head>")
builder.Append("<body>")
builder.Append("<div class = 'email-section'>")
builder.Append("<table id = 'email' class='emai_table'>")
builder.Append("<thead>")
builder.Append("<tr>")
builder.Append("<th>Field1</th>")
builder.Append("<th>Field2</th>")
builder.Append("<th>Field3</th>")
builder.Append("<th>Field4</th>")
builder.Append("<th>Field5</th>")
For Each row As DataRow In dt2.Rows
builder.Append("<tr>")
For Each col As DataColumn In dt2.Columns
builder.Append("<td>" & row(col).ToString + " " & "</td>")
Next
builder.Append("</tr>")
builder.AppendLine()
Next
builder.Append("</tbody>")
builder.Append("</table>")
builder.Append("</div>")
builder.Append("</body>")
builder.Append("</html>")
Your assistance on how to implement this would be greatly appreciated. Thank you!