Repeater中的Datalist ...只从转发器

时间:2018-04-02 15:19:12

标签: asp.net repeater nested-datalist

我是使用Repeater和Datalist的新手。

我在论坛中检查了将数据列表放在转发器中的正确方法。下面是我创建的内容,但它只在我运行时显示转发器的标题

<div id="divMarketSnapshot" style="vertical-align: central; width: 100%; height: 450px; overflow: auto" runat="server">
<asp:Repeater ID="rptrRanks" runat="server" ViewStateMode="Disabled">
<HeaderTemplate>
    <table border="0" style="border-collapse: collapse; table-layout: fixed; width:100%;vertical-align:central">
        <tr style="height: 14pt; width:100%">
            <td class="xl6220798" colspan="33" style="text-align: left; font-weight: bold;width:99.99%"></td>
        </tr>
        <tr style="height: 14pt; width:100%">
            <td class="xl1520798" style="width:3.03%"></td>
            <td class="xl1520798" style="width:3.03%"></td>
            <td class="xl1520798" style="width:3.03%"></td>
            <td class="xl1520798" colspan="27" style="text-align: left;font-size:14pt; font-weight: bold;width:81.1%"><%# DataBinder.Eval(Container.DataItem, "EventRow_Group") %></td>
            <td class="xl1520798" style="width:3.03%"></td>
            <td class="xl1520798" style="width:3.03%"></td>
            <td class="xl1520798" style="width:3.03%"></td>
        </tr>
        <tr style="height: 14pt; width:100%">
            <td class="xl6220798" colspan="33" style="text-align: left; font-weight: bold;width:99.99%"></td>
        </tr>
    </HeaderTemplate>
    <ItemTemplate>
        <asp:DataList ID="dlRanks" runat="server" RepeatColumns="2" RepeatDirection="Horizontal">
            <HeaderTemplate>
                <tr style="height: 14pt; width:100%" runat="server">
                    <td runat="server" colspan="16" class="xl6620798" style="width:48.48%">
                        <a href="<%# DataBinder.Eval(Container.DataItem, "EventRow_ChartLink") %>"  " title="<%# DataBinder.Eval(Container.DataItem, "EventRow_EventDirectionDesc") %>" target="_blank"><%# DataBinder.Eval(Container.DataItem, "EventRow_Name") %></a>
                    </td>
                    <td class="xl1520798" style="width:3.03%"></td>
                </tr>
                <tr runat="server" style="width: 100%">
                    <td class="xl6720798" colspan="2" style="width: 6.06%; text-align: center">Date</td>
                    <td class="xl6720798" colspan="2" style="width: 6.06%; text-align: center">Market<br />Forecast</td>
                    <td class="xl6820798" colspan="2" style="width: 6.06%; text-align: center">RCG<br />Forecast</td>
                    <td class="xl6920798" colspan="2" style="width: 6.06%; text-align: center">Market<br />Actual</td>
                    <td class="xl7020798" colspan="2" style="width: 6.06%; text-align: center">RCG<br />Accuracy</td>
                    <td class="xl6920798" colspan="2" style="width: 6.06%; text-align: center">Equity Market<br />End Of Day</td>
                    <td class="xl7020798" colspan="2" style="width: 6.06%; text-align: center"><%# DataBinder.Eval(Container.DataItem, "EventRow_IndexHeader") %> Index<br />End Of Day</td>
                    <td class="xl7020798" colspan="2" style="width: 6.06%; text-align: center"><%# DataBinder.Eval(Container.DataItem, "EventRow_CurrencyHeader") %><br />End Of Day</td>
                    <td class="xl1520798" style="width: 3.03%"></td>
                </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr style="width:100%">
                    <td class="xl7120798" colspan="2" style="width:6.06%; text-align: center"><%# DataBinder.Eval(Container.DataItem, "EventRow_DateTime") %></td>
                    <td class="xl7120798" colspan="2" style="width:6.06%; text-align: center"><%# DataBinder.Eval(Container.DataItem, "EventRow_Forecast") %></td>
                    <td class="<%# DataBinder.Eval(Container.DataItem, "EventRow_ForecastDirection_Change") %>" colspan="2" style="width:6.06%; text-align: center"><%# DataBinder.Eval(Container.DataItem, "EventRow_ForecastDirection") %></td>
                    <td class="xl7120798" colspan="2" style="width:6.06%; text-align: center"><%# DataBinder.Eval(Container.DataItem, "EventRow_Actuals") %></td>
                    <td class="<%# DataBinder.Eval(Container.DataItem, "EventRow_ActualMarketResult_Font") %>" colspan="2" style="width:6.06%; text-align: center"><%# DataBinder.Eval(Container.DataItem, "EventRow_ActualMarketResult") %></td>
                    <td class="<%# DataBinder.Eval(Container.DataItem, "EventRow_Equity_EOD_Change") %>" colspan="2" style="width:6.06%; text-align: center"><%# DataBinder.Eval(Container.DataItem, "EventRow_Equity_EOD_Price") %></td>
                    <td class="<%# DataBinder.Eval(Container.DataItem, "EventRow_Index_EOD_Change") %>" colspan="2" style="width:6.06%; text-align: center"><%# DataBinder.Eval(Container.DataItem, "EventRow_Index_EOD_Price") %></td>
                    <td class="<%# DataBinder.Eval(Container.DataItem, "EventRow_Currency_EOD_Change") %>" colspan="2" style="width:6.06%; text-align: center"><%# DataBinder.Eval(Container.DataItem, "EventRow_Currency_EOD_Price") %></td>
                    <td class="xl1520798" style="width:3.03%"></td>
                </tr>                                    
            </ItemTemplate>
            <FooterTemplate>
                <tr style="width:100%">
                    <td style="width:3.03%"></td>
                    <td style="width:3.03%"></td>
                    <td class="xl1520798_15" colspan="4" style="width:12.12%; text-align: left">Next Forecast:  <%# DataBinder.Eval(Container.DataItem, "EventRow_NextForecast") %></td>
                    <td style="width:3.03%"></td>
                    <td class="xl1520798_15" colspan="3" style="width:12.3%;text-align:center">Ultra Accuracy:  <span style="<%# DataBinder.Eval(Container.DataItem, "EventRow_UltraAccuracy_Style") %>"><%# DataBinder.Eval(Container.DataItem, "EventRow_UltraAccuracy") %></td>
                    <td colspan="7" style="width:21.21%"></td>
                </tr>
                <tr style = "width:100%">
                    <td class="xl6820798" colspan="33" style="width:99.99%"></td>
                </tr>
            </FooterTemplate>
        </asp:DataList>
    </table>
</ItemTemplate>

ItemDatabound上的代码隐藏:

Private Sub rptrRanks_ItemDataBound(sender As Object, e As RepeaterItemEventArgs) Handles rptrRanks.ItemDataBound 
    Dim dt As DataTable 
    Dim dlRanks As DataList = DirectCast(e.Item.FindControl("dlRanks"), DataList) 
    dt = TryCast(rptrRanks.DataSource, DataTable) 
    dlRanks.DataSource = dt 
    dlRanks.DataBind() 
End Sub

对于Datalist,我有2列数据。 我正在寻找的结构如下:

Group
Event                                            Event
data col  data col   data col                    data col  data col   data col
data col  data col   data col                    data col  data col   data col
data col  data col   data col                    data col  data col   data col
data col  data col   data col                    data col  data col   data col

Footer information                               Footer information

请告诉我需要更改的内容,以使其正常运行。

1 个答案:

答案 0 :(得分:0)

全部,我找到了一个用于执行嵌套中继器的链接。我正在处理我的代码以使其正确无误。这是链接https://www.mikesdotnetting.com/article/57/displaying-one-to-many-relationships-with-nested-repeaters