That sort of layout is tricky to accomplish with a
GridView
, but almost trivial to do with a
ListView[
^]. :)
ListView Web Server Control Overview[
^]
<asp:ListView id="GradeList" runat="server">
<LayoutTemplate>
<table>
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Grade</th>
<th scope="col">Age</th>
</tr>
</thead>
<tbody>
<tr id="itemPlaceholder" runat="server" />
</tbody>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<th scope="row">
<asp:Literal runat="server" Mode="Encode"
Text='<%# Eval("ID") %>'
/>
</th>
<td>
<asp:Literal runat="server" Mode="Encode"
Text='<%# Eval("Name") %>'
/>
</td>
<td>
<asp:Literal runat="server" Mode="Encode"
Text='<%# Eval("Grade") %>'
/>
</td>
<td>
<asp:Literal runat="server" Mode="Encode"
Text='<%# Eval("Age") %>'
/>
</td>
</tr>
<tr>
<td colspan="4">
<asp:Literal runat="server" Mode="Encode"
Text='<%# Eval("Notes") %>'
/>
</td>
</tr>
</ItemTemplate>
</asp:ListView>