开发者

insert dynamic text "google ads" on a asp.net repeater

开发者 https://www.devze.com 2023-01-07 04:06 出处:网络
I want to insert Google ads on a asp.net repeater on the 3rd iteration. I\'m trying to figure out how to do this, here is what I have.

I want to insert Google ads on a asp.net repeater on the 3rd iteration. I'm trying to figure out how to do this, here is what I have.

    <asp:Repeater ID="Repeater1" runat="server" >
            <HeaderTemplate>
            </HeaderTemplate>
            <ItemTemplate>
                <div class="Pl">
                 <%# int i=0; if(i!=3){ %>
                        <div class="PlFoto">
                   开发者_JS百科         //display content  
                        </div>
                 <%# ++i;} else {%>
                          //display Google ads
                 <%# ++i;}%>
                </div>
        </ItemTemplate>
    </asp:Repeater> 


Will "i" ever be equal to 3? Won't the "int i=0;" be executed with each iteration? Try putting that declaration outside the repeater and see if it works better.


<asp:Repeater ID="Repeater1" runat="server" >
    <HeaderTemplate>
    <% int i = 0;%>
    </HeaderTemplate>
    <ItemTemplate>
        <div class="Pl">
        <%  if (i != 3) { %>
            <div class="PlFoto"></div>
        <% ++i;}else{ %>
            <div class="ads"></div>
        <% ++i;   } %>
        </div>
    </ItemTemplate>
</asp:Repeater>
0

精彩评论

暂无评论...
验证码 换一张
取 消