Created
May 2, 2013 16:16
-
-
Save sanmadjack/5503327 to your computer and use it in GitHub Desktop.
A function to create a string containing the html table representation of a DataSet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Function PrintDataSetToHTML(ByRef ds As DataSet) As String | |
Dim output As New StringBuilder | |
For Each dt As DataTable In ds.Tables | |
output.AppendLine("<table>") | |
output.Append("<caption>") | |
output.Append(dt.TableName) | |
output.AppendLine("</caption>") | |
output.AppendLine("<tr>") | |
For Each dc As DataColumn In dt.Columns | |
output.Append("<th>") | |
output.Append(dc.ColumnName) | |
output.AppendLine("</th>") | |
Next | |
output.AppendLine("</tr>") | |
For Each dr As DataRow In dt.Rows | |
output.AppendLine("<tr>") | |
For Each dc As DataColumn In dt.Columns | |
output.Append("<td>") | |
output.Append(dr(dc)) | |
output.AppendLine("</td>") | |
Next | |
output.AppendLine("</tr>") | |
Next | |
output.AppendLine("</table>") | |
Next | |
Return output.ToString | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment