我有以下代码
List<Department> depts = new List<Department>();
Department.Add(new Department() { DNo = 1, DName = "Accounting", DFloor="6" });
Department.Add(new Department() { DNo = 2, DName = "FInance", DFloor="3" });
我想将此数据绑定到 GridView,以便它输出以下内容。观察每个 th 和 tr 上的类。如何在 ASP.NET 中实现这一点?
<thead>
<tr>
<th class="DNo">DNo</th>
<th class="DName">DName</th>
<th class= "DFloor">DFloor</th>
</tr>
</thead>
<tr>
<td class="DNo">1</td>
<td class="DName">Accounting</td>
<td class="DFloor">6</td>
</tr>
<tr>
<td class="DNo">2</td>
<td class="DName">FInance</td>
<td class="DFloor">3</td>
</tr>