我在網頁上使用轉發器渲染資料,但是資料沒有以正確的順序顯示。
<asp:Repeater ID="RepeatInformation" runat="server">
<HeaderTemplate>
<table id="tbldata" border="1" cellspacing="0" rules="all">
<tr style= "background-color: #eee;">
<th scope="col" style="width: 90px">Date</th>
<th scope="col">09:00</th>
<th scope="col">09:30</th>
<th scope="col">10:00</th>
<th scope="col">10:30</th>
<th scope="col">11:00</th>
<th scope="col">11:30</th>
<th scope="col">12:00</th>
<th scope="col">12:30</th>
<th scope="col">13:00</th>
<th scope="col">13:30</th>
<th scope="col">14:00</th>
<th scope="col">14:30</th>
<th scope="col">15:00</th>
<th scope="col">15:30</th>
<th scope="col">16:00</th>
<th scope="col">16:30</th>
<th scope="col">17:00</th>
<th scope="col">17:30</th>
<th scope="col">18:00</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("Date") %></td>
<td><%# Eval("Time1") %></td>
<td><%# Eval("Time2") %></td>
<td><%# Eval("Time3") %></td>
<td><%# Eval("Time4") %></td>
<td><%# Eval("Time5") %></td>
<td><%# Eval("Time6") %></td>
<td><%# Eval("Time7") %></td>
<td><%# Eval("Time8") %></td>
<td><%# Eval("Time9") %></td>
<td><%# Eval("Time10") %></td>
<td><%# Eval("Time11") %></td>
<td><%# Eval("Time12") %></td>
<td><%# Eval("Time13") %></td>
<td><%# Eval("Time14") %></td>
<td><%# Eval("Time15") %></td>
<td><%# Eval("Time16") %></td>
<td><%# Eval("Time17") %></td>
<td><%# Eval("Time18") %></td>
<td><%# Eval("Time19") %></td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
我已經嘗試使用下面的腳本來做到這一點,我從這里參考了它。
<%--<script>
$("#tbldata th").each(function (i, val) {
var th = $(this);
var selector = "td:nth-child(" (i 1) ")";
th.parent().siblings().find(selector).attr("#tbldata", th.attr("#tbldata"));
});
</script>--%>
目前資料是這樣顯示的
有人請建議我如何以正確的順序列顯示資料。
uj5u.com熱心網友回復:
將結束</table>標記從<ItemTemplate>移到FooterTemplate:
<HeaderTemplate>
<table>
<tr>
...
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
...
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/366416.html
