locked
ListView not creating thead RRS feed

  • Question

  • User1510859543 posted

    I have a ListView that I want to output both a THEAD and a TBODY element.  Currently it just outputs a TABLE and TBODY followed by the heading and data contents in separate TR elements.  My LayoutTemplate is below.  What am I missing?

            <LayoutTemplate>
                <table id="Table1" runat="server" border="0" cellpadding="0" cellspacing="0" width="99%" class="scrollTable">
                    <thead class="fixedHeader">
                        <tr>
                            <th id="Th1" runat="server">
                                LogID</th>
                            <th id="Th2" runat="server">
                                LoginDateTime</th>
                            <th id="Th3" runat="server">
                                LogType</th>
                            <th id="Th4" runat="server">
                                RecordID</th>
                            <th id="Th5" runat="server">
                                VendorID</th>
                            <th id="Th6" runat="server">
                                InsuranceID</th>
                            <th id="Th7" runat="server">
                                LogSubType</th>
                        </tr>
                    </thead>
                    <tbody class="scrollContent">
                        <tr ID="itemPlaceholder" runat="server">
                        </tr>
                    </tbody>
                </table>
            </LayoutTemplate>
    

    Friday, December 16, 2016 9:03 PM

Answers

  • User-6180675 posted

    Just remove the runat="server" attribute from the <table> tag inside your listview layout template control.Also I have removed the same from <th> tags , if you are not accessing them from server side. Check the modified code below

    <LayoutTemplate>
                <table id="Table1" border="0" cellpadding="0" cellspacing="0" width="99%" class="scrollTable">
                    <thead class="fixedHeader">
                        <tr>
                            <th id="Th1">
                                LogID</th>
                            <th id="Th2">
                                LoginDateTime</th>
                            <th id="Th3">
                                LogType</th>
                            <th id="Th4">
                                RecordID</th>
                            <th id="Th5">
                                VendorID</th>
                            <th id="Th6" >
                                InsuranceID</th>
                            <th id="Th7">
                                LogSubType</th>
                        </tr>
                    </thead>
                    <tbody class="scrollContent">
                        <tr ID="itemPlaceholder" runat="server">
                        </tr>
                    </tbody>
                </table>
            </LayoutTemplate>

    Let me know if it works for you. The table is treated as server side control with the runat="server" attribute. Check the below link

    http://www.java2s.com/Tutorial/ASP.NET/0380__Data-Binding/UseaListViewcontroltorenderanHTMLtable.htm

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 17, 2016 8:48 AM