简体   繁体   English

嵌套中继器-如何在不使用runat服务器标签的情况下访问第3级项目?

[英]Nested repeaters - How to access item on 3rd level without runat server tag?

Hi i have a 3 tiered nested repeater and i need to access the values in the repeater condRptr below on postback, i tried everything but dont seem to be able to get anywhere. 嗨,我有一个3层嵌套的转发器,我需要在回发时访问下面的转发器condRptr中的值,我尝试了所有操作,但似乎无法到达任何地方。 I had the table originally within the repeater with runat server in the header template but this threw an error. 我最初在表头模板中将表包含在具有runat服务器的转发器中,但这引发了错误。

Anyone got any ideas?? 任何人有任何想法吗?

<asp:Repeater ID="deptRepeater" runat="server" OnItemDataBound="bindDepts">
                <HeaderTemplate>

                </HeaderTemplate>
                <ItemTemplate>
                <div id="itemContainer">
                    <h3 class="fdAccordionHeader"><%# Eval("desc") %><span class="fdAccordionHeaderIcon"></span></h3><asp:HiddenField ID="deptid" runat="server" Value='<%# Eval("dept_id") %>' />
                        <div class="fdAccordionContent" style="display:none">
                            <asp:Repeater ID="prodRepeater" runat="server" OnItemCommand="itemToCart">
                                <HeaderTemplate>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <div>
                                    <h4 class="fdProductHeader"><span class="fdProductHeaderTitle"><%# Eval("desc") %></span><span class="fdProductFeatured"></span><span class="fdProductHeaderPrice">€<%# Eval("price") %></span><span class="fdClearBoth"></span></h4>
                                    <div class="fdProductContent" style="display:none">
                                        <img class="fdProductImage" src="http://wingit.ie/script/app/web/img/frontend/noimg.png" alt="">
                                        <div class="fdProductContentRight">
                                            <div class="fdProductDesc">A helping of our delicious wings, served with fries and a drink of your choice. Perfect if you're particularly hungry!</div>

                                                    <input type="hidden" name="product_id" value="2">
                                                    <!--<a href="#" class="fdButton fdButtonOrder"></a>-->
                                                    <asp:LinkButton ID="btnOrder" runat="server" CssClass="fdButton fdButtonOrder" CommandName="addToCart" CommandArgument='<%# Eval("product") %>' ></asp:LinkButton>
                                                    <table id="condimentsContainer" cellpadding="0" cellspacing="0" runat="server">

                                                    <asp:Repeater ID="condRptr" runat="server">

                                                        <ItemTemplate>
                                                        <tr><td>
                                                            <table id='condiments' cellpadding="0" cellspacing="0" class="fdProductExtraTbl" runat="server">
                                                                <tbody>
                                                                    <tr>
                                                                        <td><%# Eval("pDesc") %></td>
                                                                        <td class="fdProductExtraTblPrice"><asp:Label ID="priceLvl" runat="server">€<%# Eval("pPrice") %> x</asp:Label> 
                                                                            <input id="modifier" class="modifier" type="text" name="extra_id[3]" value="0" runat="server"/>
                                                                            <input id="hdProd" type="hidden" value='<%# Eval("pCode") %>' runat="server"/>
                                                                        </td>
                                                                        <td class="fdProductExtraTblIco"><a href="#" data-eid="3" data-pid="2" class="fdProductExtraIcon fdProductExtraIconPlus"></a></td>
                                                                        <td class="fdProductExtraTblIco"><a href="#" data-eid="3" data-pid="2" class="fdProductExtraIcon fdProductExtraIconMinus"></a></td>
                                                                    </tr>
                                                        </tbody>
                                                            </table>
                                                            </td></tr>
                                                        </ItemTemplate>
                                                    </asp:Repeater>
                                                    </table>
                                            </div>
                                            <span class="fdClearLeft"></span>
                                        </div>
                                    </div>
                                </ItemTemplate>
                                <FooterTemplate>
                                </FooterTemplate>
                            </asp:Repeater>
                        </div>    
                  </div>          
                </ItemTemplate>
                <FooterTemplate>
                </FooterTemplate>
            </asp:Repeater>

Ok so as no-one had any ideas ;) i eventually figured out a nifty work around for this, because i couldn't have the runat server in the header template, i basically put it in the element like so 好的,因为没有人有任何想法;)我最终想出了一个不错的解决方法,因为我无法在头模板中使用runat服务器,所以基本上将其放在这样的元素中

<tr ID="dataRow" runat="server"> rest of data </tr>

Then in the C# code on the server side i was able to use the RepeatEreventArgs and cast the as a HtmlTableRow so that i could iterate through the data - simples :) 然后在服务器端的C#代码中,我能够使用RepeatEreventArgs并将其强制转换为HtmlTableRow,以便我可以遍历数据-简单:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM