0

I want to run repeater control loop twice to show only two news items and i want to hide <hr> tag after first loop. I am not sure how i can use container.index method to hide hr tag .

<asp:repeater id="rptRepeater" runat="server">
    <separatortemplate>
                  <div id="one"><%=getTitle('title')%></div>
                  <div id="two"><%=getDescription('Desc')%></div>
          <hr id="hr" runat="server">
    </separatortemplate>
</asp:repeater>

I dont want to use jQuery for this i want to do it either from code behind or some repeater control property

Can i do something like <% if Container.index > 1 %> ... <% else %> ... in the same line where hr tag is included.

4

1 回答 1

0

尝试这个:

<asp:repeater id="rptRepeater" runat="server">
    <separatortemplate>
                  <div id="one"><%=getTitle('title')%></div>
                  <div id="two"><%=getDescription('Desc')%></div>
          <hr id="hr" runat="server" style='<%# (Container.index > 1)?"display:none;":""' %> >
    </separatortemplate>
</asp:repeater>
于 2013-09-09T06:05:20.743 回答