我有一个看起来像这样的对象:
public class TestData
{
public string FirstName {get; set;}
public string LastName {get; set;}
public string Email {get; set;}
public string Phone {get; set;}
}
我有 10 个该类的实例存储在IENumerable
.
GridView
我的文件中也有一个aspx
:
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
我需要的是一种IENumerable
在GridView
. 但我希望能够thead
自己在表格中设置“标题”。
所以我得到这样的东西:
<table>
<thead>
<th>Firstname</th>
<th>Firstname</th>
<th>Telephone</th>
<th>Email address</th>
</thead>
<tbody>
<!-- the values from each TestData class stored in the IENumberable -->
</tbody>
</table>
我可以使用 a 来执行此操作,GridView
还是使用其他控件更好地完成这项工作?我还记得一些关于模板的事情?不确定,我对 ASP.NET 很陌生。