Determine the number of repeater lines in asp.net

How can I determine the number of lines displayed in this repeater immediately?

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="News" EnableViewState="true">
  <ItemTemplate>
    <hr />
    <div style="color:#036e90; font-weight: bold; font-family:Tahoma; text-align:center ; padding-left:10px"><a href="DisplayNews.aspx"><%#DataBinder.Eval(Container.DataItem, "News_Name")%></a></div>
                <div style=" FONT-SIZE: 10pt;  FONT-FAMILY: Tahoma ; text-align:center;padding-left:10px"><%#DataBinder.Eval(Container.DataItem, "News_Description")%></div>
    <br />
             <hr  />
  </ItemTemplate>
</asp:Repeater>
+7
source share
3 answers

After doing a lot of google, I finally got the answer: ((yourDataSourceDataType) rpttags.DataSource) .count

Where rpttags is the identifier of your repeater.

http://dotnetacademy.blogspot.com/2011/08/rowitem-count-in-repeater.html

+6
source

This should work too:

((Container.Parent as a relay) .DataSource as an IList) .Count

+4
source

<%# Container.ItemIndex %> .

.

, <a>.

<div id="accordion" class="mb-3">
  <div class="card eventAccordion closed">
    <div id="headingOne" class="card-header">
    </div>
    <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
      <div class="card-body" id="child1">
        <asp:Repeater runat="server" ID="myId">
          <ItemTemplate>
            <div class="card">
              <div class="card-header">
                <a href="#" class="btn-link d-inline-flex" data-toggle="collapse" data-target="#collapseOne<%# Container.ItemIndex %>">
                </a>
              </div>
              <div class="card-body collapse" data-parent="#child1" id="collapseOne<%# Container.ItemIndex %>">
              </div>
            </div>
          </ItemTemplate>
        </asp:Repeater>
      </div>
    </div>
  </div>
</div>
+1

All Articles