我用一个repeter控件反复一个table,比如说反复4次
现在需要的是前2个中有个图片,后2个没有即:
table1......image1
table2......image1
table3......
table4......
repeter有没有这个功能
怎样才能实现?
谢谢<asp:Repeater Runat="server" ID="temp">
<ItemTemplate>
<TABLE id="tab1" cellSpacing="0" cellPadding="0" width="244" border="0">
<TR bgColor="#f7f3f7">
<TD width="24" bgColor="#f7f3f7" height="22">
<DIV align="center"><FONT size="2"><IMG height="9" src="images/icon_04.gif" width="9"></FONT></DIV>
</TD>
<TD width="220" height="22">
<DIV align="left"><SPAN class="style2"><A class="px12_gray_04" href="http://babyq.8bao.com/syjq.aspx" target="_blank">使用技巧</A><FONT face="Arial" color="#333333" size="2">

<IMG height="11" src="images/就是这个图片!!!.gif" width="25"></FONT></SPAN></DIV>
</TD>
</TR>
<TR>
<TD background="images/Form_8x1_x.gif" colSpan="2" height="1"><FONT face="Arial" color="#333333" size="2"><IMG height="1" src="images/Form_1x1_d.gif" width="1"></FONT></TD>
</TR>
</TABLE>
</ItemTemplate>
</asp:Repeater>

if(e.Item.ItemIndex < 2)
{}里怎么写?请指教
谢谢~

解决方案 »

  1.   

    估计没有吧。如果为了实现
    你可以分成两个repeater。
    或者,使用一个repeater,都去显示image。但是后边的image visible false了。  
        组织的数据为:
                    id,image,imageVisible(值为0或1)
    前两条数据imageVisible为1,后边的都为0。
    然后前台visible=imagevisible的值也可以的。还可以再repeater的itembound事件中,添加前台的image。
      

  2.   

    又发现一个好方法:
    <asp:Repeater id="Repeater1" runat="server">
    <ItemTemplate>
    <table width="100%" runat="server" Visible='<%#Container.itemIndex <2%>'>
    <tr>
      <td><img border="0" src='images/<%#Container.DataItem("pic_name")%>'></td>
    </tr>
    </table>
    <table width="100%" runat="server" Visible='<%#Container.itemIndex >=2%>'>
    <tr>
    <td><%#Container.Dataitem("title")%></td>
    </tr>
    </table>
    </ItemTemplate>
    </asp:Repeater>