【发布时间】:2014-06-06 00:22:24
【问题描述】:
我正在尝试使用基于 c# 函数在单击按钮时返回的内容填充行的 html 表。
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Populate" /></div><br>
<table id ="randtable" class="tablex">
<tr>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
<th>Col4</th>
</tr>
</table>
我的 Button1_Click 函数如下所示:
protected void Button1_Click(object sender, EventArgs e)
{
List<Entity> x = someFunction();
//I want to have each row in the table represent each entity. Assume each entity has 4 attributes which would go in Col1,Col2,Col3,Col4 in the table.
}
知道怎么做吗?我坚持使用 html 表格而不是 asp 控制表格的原因是为了保留 html 表格的 css,除非有办法让 asp 表格看起来也很吸引人。
【问题讨论】:
-
尝试众多 ASP.net 数据控件之一:GridView、ListView、Repeater。它们的设计考虑到了这一点。中继器是“最轻”的选项。 Gridview 可能是最重的。
-
ASP.net 控件有一个名为“CssClass”的属性,它与 HTML 控件的“类”相同..
标签: c# javascript jquery html asp.net