Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I just had this come up: you don't need to use CSS, just define your header row in your Layout Template as a separate table. then wrap a new table in a div with <code>overflow=scroll</code> and drop your contentplace holder right in. </p> <p>Notice there is an extra column in the header this is to make room for the scroll bar. Then set the width of your columns the same as your headers and you are done. </p> <p>You will have to include some JavaScript to keep your scroll position after postback but that's a different thread. Here is an example of how I accomplished it.</p> <pre><code>&lt;asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1"&gt; &lt;EmptyDataTemplate&gt; &lt;table id="Table1" runat="server" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;"&gt; &lt;tr&gt; &lt;td&gt; No data was returned.&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/EmptyDataTemplate&gt; &lt;ItemTemplate&gt; &lt;tr style="background-color: #E0FFFF;color: #333333;"&gt; &lt;td style="width:100px;"&gt; &lt;asp:LinkButton ID="Butpullacct" OnClick="Butpullacct_Click" runat="server"&gt;Reaccess&lt;/asp:LinkButton&gt; &lt;/td&gt; &lt;td style="display:none"&gt; &lt;asp:Label ID="idLabel" runat="server" Text='&lt;%# Eval("id") %&gt;' /&gt; &lt;/td&gt; &lt;td style="width:100px;"&gt; &lt;asp:Label ID="BTNRSLabel" runat="server" Text='&lt;%# Eval("BTNRS") %&gt;' /&gt; &lt;/td&gt; &lt;td style="width:100px;"&gt; &lt;asp:Label ID="NoticeDueLabel" runat="server" Text='&lt;%# Eval("NoticeDue")%&gt;' /&gt; &lt;/td&gt; &lt;td style="width:75px;"&gt; &lt;asp:Label ID="NoticeTypeLabel" runat="server" Text='&lt;%# Eval("NoticeType") %&gt;' /&gt; &lt;/td&gt; &lt;td style="width:200px;"&gt; &lt;asp:Label ID="DispDescLabel" runat="server" Text='&lt;%# Eval("DispDesc") %&gt;' /&gt; &lt;/td&gt; &lt;td style="width:175px;"&gt; &lt;asp:Label ID="AccessTimeLabel" runat="server" Text='&lt;%# Eval("AccessTime") %&gt;' /&gt; &lt;/td&gt; &lt;td style="width:175px;"&gt; &lt;asp:Label ID="ExitTimeLabel" runat="server" Text='&lt;%# Eval("ExitTime") %&gt;' /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;LayoutTemplate&gt; &lt;table id="Table2" runat="server"&gt; &lt;tr id="Tr1" runat="server"&gt; &lt;td id="Td1" runat="server"&gt; &lt;table ID="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;"&gt; &lt;tr id="Tr2" runat="server" style="background-color: #E0FFFF;color: #333333;"&gt; &lt;th id="Th1" runat="server" style="width:100px;"&gt;&lt;/th&gt; &lt;th id="Th2" runat="server" style="display:none"&gt; id&lt;/th&gt; &lt;th id="Th3" runat="server" style="width:100px;"&gt; BTNRS&lt;/th&gt; &lt;th id="Th4" runat="server" style="width:100px;"&gt; Notice Due Date&lt;/th&gt; &lt;th id="Th5" runat="server" style="width:75px;"&gt; Notice Type&lt;/th&gt; &lt;th id="Th6" runat="server" style="width:200px;"&gt; Action&lt;/th&gt; &lt;th id="Th7" runat="server" style="width:175px;"&gt; Access Time&lt;/th&gt; &lt;th id="Th8" runat="server" style="width:175px;"&gt; Exit Time&lt;/th&gt; &lt;th id="Th9" style="width:13px;" runat="server"&gt; &lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div style="overflow:scroll; height:500px;"&gt; &lt;table border="1" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;"&gt; &lt;tr ID="itemPlaceholder" runat="server"&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr id="Tr3" runat="server"&gt; &lt;td id="Td2" runat="server" style="text-align: center;background-color: #5D7B9D;font-family: Verdana, Arial, Helvetica, sans-serif;color: #FFFFFF"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/LayoutTemplate&gt; &lt;/asp:ListView&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload