more of newbies 🙂
I’ve created HTML table using below html code
<table runat="server" id="Table1" border="1" class="style1">
<tr>
<td class="style2" colspan="3">
Info.</td>
<td class="style2" colspan="2">
TypeA</td>
<td class="style2">
TypeB</td>
<td class="style2" rowspan="2">
TypeC</td>
</tr>
<tr>
<td class="style3">
Dept.</td>
<td class="style3">
Div.</td>
<td class="style3">
Unit</td>
<td class="style3">
TypeA.1</td>
<td class="style3">
TypeA.1</td>
<td style="text-align: center">
TypeB.1</td>
</tr>
</table>
I tried to add row for it using
protected void Button1_Click(object sender, EventArgs e)
{
TableRow tRow = new TableRow();
for (int i = 1; i < 8; i++)
{
TableCell tb = new TableCell();
tb.Text = "text";
tRow.Controls.Add(tb);
}
Table1.Rows.Add(tRow);
}
but I got :
The best overloaded method match for ‘System.Web.UI.HtmlControls.HtmlTableRowCollection.Add(System.Web.UI.HtmlControls.HtmlTableRow)’ has some invalid arguments
I googled around but with no luck.
I’m doing this to avoid Columns Heading merging action in code behind while I still have to look for how to merge rows heading. This is the last step for completing https://stackoverflow.com/questions/13670384/asp-net-dynamic-input-display-table-by-section-with-multi-columns-rows-headers
,.. closer heading view is:

Rows created will have a forwarding heading cell that should be merged if it’s the same with row above. Appreaciate the great assistant from StackOverflow members.
The error is apparent in the exception.
You are using
TableRowinstead ofHtmlTableRow.Hover over
TableRow tRow = new TableRow();to see which namespace is theTableRowclass from.A similar change for cell would be required. i.e. use
HtmlTableCellinstead ofTableCell.EDIT:
Table,TableRoware classes fromSystem.Web.UI.WebControlsnamespace.Whereas,
HtmlTable,HtmlTableRoware classes fromSystem.Web.UI.HtmlControlsnamespace.