We help IT Professionals succeed at work.
Get Started

how to get values from repeater cells

ggaarryy asked
Last Modified: 2012-06-27
I need to get some cell values from a repeater in a clicked button event by looping thru the repeater. I want to get the "teamnumber" and the "totalwins" values.
          foreach (RepeaterItem item in Repeater1.Items)
               // This doesn't work and i dont know how to code this
               teamnumber = ((DataBoundLiteralControl)item.Controls[0]).Text;


        <table id="ScheduleTable" style="display: none">
            <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSourceScheduleRepeater">
                            <%# Eval("TeamNumber") %>
                            <%# Eval("TotalWins") %>

        <asp:SqlDataSource ID="SqlDataSourceScheduleRepeater" runat="server" ConnectionString="<%$ ConnectionStrings:CISoftballConnectionString %>"
            SelectCommand="SELECT Teams.TeamNumber, COUNT(Teams.TeamNumber) AS TotalWins FROM Leagues INNER JOIN Teams ON Leagues.Year = Teams.Year AND Leagues.LeagueId = Teams.LeagueId INNER JOIN ScheduleTeams ON Teams.TeamNumber = ScheduleTeams.TeamIdWon WHERE (Leagues.Year = '2011') AND (Leagues.LeagueId = @lid) GROUP BY Teams.TeamNumber">
                <asp:ControlParameter ControlID="DropDownListLeagues" Name="lid" PropertyName="SelectedValue" />
Watch Question
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE