I have a standard dataset that I get from my SQL server 2008 database..
ID Name
1 Joe
2 Ted
where I use c# to typically handle the data and add it to a table.
I’d like to create a table in javascript on my page, but I’m not sure where to begin.
There is obvioulsy more columns and rows in this table, but I included only a small portion of the data for ease.
<div id="divWhatIf" runat="server">
<table id="tblWhatIfByMonth" border="1" cellpadding="0" cellspacing="0" runat="server">
<tr id="rowWhatIfHeaderRow" runat="server">
</tr>
</table>
</div>
My aspx page looks like and I’d like to add each datarow to tblWhatIfByMonth.
You can use AJAX to get the content for the table. The response text can be the entire markup for the table (which makes life quite easy) or if only part of the table needs to be replaced, send the data as JSON formatted text.
The JSON is converted to an object that can then be used to create the table, e.g.
or
You can also send CSV data and parse it (say with a regular expression) and build all or part of a table.