如何在asp.net的代码隐藏文件中的表中插入<th>标签?

Bri*_*tel 3 asp.net html-table code-behind tablerow

我在文件后面的代码中添加表。我想在其中添加标签。

<table id="tbl" runat="server">
   <tr>
        <th>test</th>
       <td>
       </td>
   </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

我不知道如何通过代码添加。

那么谁能告诉我如何添加标签?

Rop*_*tah 5

HtmlTable t = tbl; //just to make it clear your table is an HtmlTable
tbl.Rows[0].Cells.Add(new HtmlTableCell("th")); //adds an emtpy cell to the first row with th tagname
Run Code Online (Sandbox Code Playgroud)