insert dynamic text "google ads" on a asp.net repeater
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>
精彩评论