I have 7 columns in a gridview. the 7th column holds a 50 word description of the other six. Where can i find help seeing how to lay out the rows so that the 6 fields appear and then the 7th is underneath it. i am struggling to find the template sample, or datalist view, or gridview that shows a sample of how to lay that out properly. Intellisense is so cryptic to me. Visual Studio 2008 newbie linked to a database with 7 columns.
A:
Hi David--
Unfortunately, I don't believe there's an easy way to add a second row to each GridView record.
If you don't need the built-in sorting/editing/deleting that the GridView offers, might I recommend the ListView control? This would allow you to write very specific HTML code for each data item, giving you the ability to create the additional 2nd row for each item.
Hope this helps! --Jeremy
Jeremy Kratz
2009-05-28 14:05:18
A:
Without any idea of what data you are playing around with why not try a Repeater control? I have got an example for you below:
<asp:Repeater ID="R_Data" runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("Item 1") %></td>
<td><%# Eval("Item 2") %></td>
<td><%# Eval("Item 3") %></td>
<td><%# Eval("Item 4") %></td>
<td><%# Eval("Item 5") %></td>
<td><%# Eval("Item 6") %></td>
</tr>
<tr>
<td colspan="6"><%# Eval("Item 7") %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
This would create code similar to:
<table>
<tr>
<td>Item 1</td>
<td>Item 2</td>
<td>Item 3</td>
<td>Item 4</td>
<td>Item 5</td>
<td>Item 6</td>
</tr>
<tr>
<td colspan="6">Item 7</td>
</tr>
</table>
The two lines would repeat for each row of the DataSource that you feed the Repeater control.
------------------------------------------------------- | Item 1 | Item 2 | Item 3 | Item 4 | Item 5 | Item 6 | ------------------------------------------------------- | Item 7 | -------------------------------------------------------
Ian Roke
2009-05-29 22:10:02