We help IT Professionals succeed at work.
Get Started

how to get values from repeater cells

ggaarryy
ggaarryy asked
on
2,429 Views
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">
                <ItemTemplate>
                    <tr>
                        <td>
                            <%# Eval("TeamNumber") %>
                        </td>
                        <td>
                            <%# Eval("TotalWins") %>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
        </table>

        <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">
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownListLeagues" Name="lid" PropertyName="SelectedValue" />
            </SelectParameters>
        </asp:SqlDataSource>
Comment
Watch Question
Commented:
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