Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET ListView - Render THEAD/TBODY Tags

I have an ASP.NET ListView control (see below).

Unfortunately, when a ListView control is rendered is does so absent of HTML tags such as THEAD/TBODY.

This is causing a problem for me because the CSS styling that I'm using needs those tags.

<asp:ListView ID="ListView" runat="server" DataKeyNames="Id">
        <LayoutTemplate>
            <div id="tableContainer" class="tableContainer">
                <table runat="server" class="scrollTable" >
                  <thead class="fixedHeader">
                    <tr>
                        <th>
                            <span>Column1</span>
                        </th>                           
                    </tr>
                   </thead>
                   <tbody class="scrollContent">
                    <tr id="itemPlaceholder" runat="server" />
                   </tbody>
                </table>
            </div>
        </LayoutTemplate>
        <ItemTemplate>
            <tr id="items" runat="server">
                <td class="first">
                    <%#Eval("Column1")%>
                </td>                    
            </tr>
        </ItemTemplate>
    </asp:ListView>

Any way I can get those tags to render?

I'm looking for a clean solution and I am open to using jQuery Prepend/Append (if possible) to achieve success.

like image 705
J.C. Avatar asked May 20 '10 21:05

J.C.


1 Answers

It is cause you mark table as runat element

<table runat="server" class="scrollTable" >

May be ASP.NET Forms framework realization causes a parsing of table content with removing "thead" tags.

Try to realize your layout without marking table tag with runat="server". I tried it and thead tag is rendered.

like image 117
chapluck Avatar answered Oct 14 '22 11:10

chapluck