dynamic lstData = {
(new {
Name = "Fruit",
Type = "นา,หำ,มี"
}),
(new {
Name = "Vegetable",
Type = "น้อย,หอย,ไม่รักดี"
})
}.ToList();
StringBuilder sb = new StringBuilder();
for (int i = 0; i <= lstData.Count - 1; i++) {
sb.Append("<tr>");
sb.Append("<td><b>" + lstData(i).Name + "</b></td>");
sb.Append("</td>");
string[] spData = lstData(i).Type.Split(",");
for (int j = 0; j <= spData.Count - 1; j++) {
sb.Append("<tr>");
sb.Append("<td style='padding-left:10px;'>" + spData(j) + "</td>");
sb.Append("</td>");
}
}
ltrRows.Text = sb.ToString();
Code (VB.NET)
Dim lstData = {(New With {.Name = "Fruit", .Type = "นา,หำ,มี"}),
(New With {.Name = "Vegetable", .Type = "น้อย,หอย,ไม่รักดี"})
}.ToList()
Dim sb As New StringBuilder()
For i As Integer = 0 To lstData.Count - 1
sb.Append("<tr>")
sb.Append("<td><b>" & lstData(i).Name & "</b></td>")
sb.Append("</td>")
Dim spData() As String = lstData(i).Type.Split(",")
For j As Integer = 0 To spData.Count - 1
sb.Append("<tr>")
sb.Append("<td style='padding-left:10px;'>" & spData(j) & "</td>")
sb.Append("</td>")
Next
Next
ltrRows.Text = sb.ToString()