更多的新手:)從代碼中添加行現有的HTML桌子後面
我用下面的HTML代碼創建的HTML表格的
<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>
我試圖添加一行它使用
爲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);
}
但我得到:
最好的超載對於「System.Web.UI.HtmlControls.HtmlTableRowCollection.Add(System.Web.UI.HtmlControls.HtmlTableRow)」 ED方法匹配具有一些無效參數
我用Google搜索周圍,但沒有運氣。
我這樣做是爲了避免列標題合併行爲在代碼後面,而我仍然需要尋找如何合併行標題。這是完成https://stackoverflow.com/questions/13670384/asp-net-dynamic-input-display-table-by-section-with-multi-columns-rows-headers
,..接近標題視圖中的最後一個步驟是:創建將有應合併是否與上述行相同的轉發標題細胞
行。 Appreaciate從StackOverflow成員偉大的助理。
不確定,但可能是現有表格行的行類型。或排應該是三列 –