views:

19

answers:

2

What I'd like to do is create a second row that spans the others within a GridView. The idea is that it is data within the GridViewRow, say a long varchar() in col 4. But when translating to HTML, how would I put that in a second row?

<table>
    <tr>
        <td></td>
        <th>ru sure?</th>
        <th>date</th>
        <th>category</th>
    </tr>
    <tr>
        <td rowspan="2"><a href=" ">edit</a></td>
        <td>yes</td>
        <td>"12/31/2009"</td>
        <td>website feedback</td>
    </tr>
    <tr>
        <td colspan="3"><textarea rows="3" cols="50"></textarea></td>
    </tr>
</table>

I can take care of the cell output, but I don't know how to terminate one row and begin another. Logically, it still represents one row of data.

A: 

Have you looked at the ListView control? It allows for some very complex layouts.

http://msdn.microsoft.com/en-us/library/bb398790.aspx

Raj Kaimal
Ooo. That looks wicked sweet. Now I _really_ wish I had VS2008...
end-user
A: 

One techniquehack that I've used is to have the last regular column of the GridView be a TemplateField, and then put the extra row in there. For example, something like this:

<asp:GridView runat="server">
    <Columns>
        <asp:BoundField/>
        <asp:BoundField/>
        <asp:BoundField/>
        <asp:TemplateField>
            <ItemTemplate>
                <%#Eval("category")%>
            </td></tr>
            <tr><td colspan="3">
                <textarea rows="3" cols="50"></textarea>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
bdukes
Yeah, that might work, but I need it for every row. It's basically taking the place of one column.
end-user
This solution will add a `colspan` row under each row of the grid. That is, each item bound to your grid will have two rows (one with three columns, one with one column). Are you looking for something different?
bdukes