Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
579 views
in Technique[技术] by (71.8m points)

.net - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...