how to get values from repeater cells

ggaarryy
ggaarryy used Ask the Experts™
on
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

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
. I don't have a asp:label in my html nor do  i have a checkbox so i still dont know how to do it.

 
Commented:
      you don't need the foreach, just do below.

 <table id="ScheduleTable" style="display: none">
            <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSourceScheduleRepeater">
                <ItemTemplate>
                    <tr>
                        <td>
                            <asp:Literal id="litTeamNumber Text='<%# Eval("TeamNumber") %>' runat="server"/>
                        </td>
                        <td>
                            <asp:Literal id="litTotalWins" Text='<%# Eval("TotalWins") %>' runat="server"/>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
        </table>

        <asp:SqlDataSource ID="SqlDataSourceScheduleRepeater" runat="server" ConnectionString="<%$ ConnectionStrings:CISoftballConnectionString %>"
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Author

Commented:
I've requested that this question be deleted for the following reason:

not answered to my satisfaction

Commented:
These solutions should work.  Can you clarify why it was not met to your satisfaction?  Code examples and explanations were given.

Author

Commented:
I don't have time for this but if you understand my original question you will see that my question was not answered.

Commented:
Sorry to inconvenience you but we give you our time to help you out with your issues.

Author

Commented:
was my question answered?

Author

Commented:
question: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.
answer :you don't need the foreach, just do below.
-------------------------------------------------------------------------
expert comment :Please check these Links:
http://www.tek-tips.com/viewthread.cfm?qid=1209235&page=1
http://stackoverflow.com/questions/681057/retrieve-the-value-of-td-in-repeater 

my comment:  I don't have a asp:label in my html nor do  i have a checkbox so i still dont know how to do it.
--------------------------------------------------------------------------
my comment::  was my question answered?

expert comment: EE policy requires you to respond to all Expert comments before deleting your question (and it's just common courtesy). Also, EE is a highly collaborative environment, and as such the Experts expect you to respond to their suggestions so that they may continue assisting you. Failing to respond to Expert comments, as you did in this question, would lead the Expert to assume that you are no longer interested in pursuing a solution. Also, other experts who vie question would see that you've not responded, and would assume you've either lost interest or no longer require a solution.

I'd also caution you against the tone of your responses. There's little to be gained by being combative, and you are expected to remain professional in all dealings with other EE members.
-------------------------------------------------------------------------------------------
I did respond to the experts comments and I then i found a solution to my problem on my own.
Then i got emails that i should close the question. so i tried to close the question and then i have to have a reason for closing the question. So i gave a reason and the reason wasn't good enough.
What is the tone of this comment from EE?  (These solutions should work.  Can you clarify why it was not met to your satisfaction?  Code examples and explanations were given. )  This is when I said i didn't have time for this. I am on to something else now and this should be behind me. I guess if i am not a good customer i should probably cancel. I have had previous questions answered and awarded the points to the expert. sorry about all this.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial