troubleshooting Question

how to get values from repeater cells

Avatar of ggaarryy
ggaarryy asked on
ASP.NET
9 Comments1 Solution2434 ViewsLast Modified:
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>
ASKER CERTIFIED SOLUTION
edemcs

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros