473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How can I loop through the repeater items?

I have a question how I can evaluate the item values. I want to know which radiobutton is true in order to save the value it represents. the code is this:
Expand|Select|Wrap|Line Numbers
  1. <asp:Repeater id="futuregames" runat="server">
  2.       <headertemplate>
  3.         <table class="fixtures">
  4.           <tr>
  5.             <th colspan="3">Game</th>
  6.             <th colspan="3">Your prediction</th>
  7.           </tr>
  8.       </headertemplate>
  9.       <ItemTemplate>
  10.           <tr>
  11.             <td><%# container.dataitem("team1") %></td>
  12.             <td>v</td>
  13.             <td><%# container.dataitem("team2") %></td>
  14.             <td><label><input type="radio" name="game<%# container.dataitem("idCompetition") %>" value="<%# container.dataitem("idTeam1") %>" /> <%# container.dataitem("teamshort1") %></label></td>
  15.             <td><label><input type="radio" name="game<%# container.dataitem("idCompetition") %>" value="<%# container.dataitem("idTeam2") %>" /> <%# container.dataitem("teamshort2") %></label></td>
  16.             <td><label><input type="radio" name="game<%# container.dataitem("idCompetition") %>" value="0" /> equal<label></td>
  17.           </tr>
  18.       </ItemTemplate>
  19.       <FooterTemplate>
  20.         </table>
  21.       </FooterTemplate>
  22.     </asp:Repeater>
  23.  
In the code behind I can cycle through the items with this code:
Expand|Select|Wrap|Line Numbers
  1. Protected Sub submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit.Click
  2.         Dim item As System.Web.UI.WebControls.RepeaterItem
  3.         Dim count As Integer
  4.         Dim temp As String
  5.  
  6.         count = 0
  7.         For Each item In futuregames.Items
  8.             If item.ItemType = ListItemType.Item Or item.ItemType = ListItemType.AlternatingItem Then
  9.               'Here I need to read the various values in order to save them.
  10.             End If
  11.  
  12.  
  13.             count = count + 1
  14.         Next
  15.     End Sub
  16.  
The cycling through the items goes well. I build in the counter to see how many records there are (7 in my case).
Problem: I need the values of the radiobuttons that are clicked so I can save them.
Oct 24 '07 #1
2 4992
mzmishra
390 Expert 256MB
RadioButton rb1=(RadioButton)item.FindControl("RadioButtonID") ;
if(rb1.Checked)
then do what ever you want
Oct 24 '07 #2
I addapted the code to this
Expand|Select|Wrap|Line Numbers
  1. <asp:Repeater id="GameFuture" runat="server">
  2.       <headertemplate>
  3.         <table class="fixtures">
  4.           <tr>
  5.             <th colspan="3">Game</th>
  6.             <th colspan="3">Prediction</th>
  7.           </tr>
  8.       </headertemplate>
  9.       <ItemTemplate>
  10.           <tr>
  11.             <td><%# container.dataitem("team1") %></td>
  12.             <td>v</td>
  13.             <td><%# container.dataitem("team2") %></td>
  14.             <td><input type="hidden" id="Game<%# container.dataitem("idCompetition") %>" value="<%# container.dataitem("idCompetition") %>" /></td>
  15.             <td><input type="radio" id="Win1<%# container.dataitem("idCompetition") %>" name="Game<%# container.dataitem("idCompetition") %>" value="<%# container.dataitem("idTeam1") %>" /> <%# container.dataitem("teamshort1") %></td>
  16.             <td><input type="radio" id="Win2<%# container.dataitem("idCompetition") %>" name="Game<%# container.dataitem("idCompetition") %>" value="<%# container.dataitem("idTeam2") %>" /> <%# container.dataitem("teamshort2") %></td>
  17.             <td><input type="radio" id="Equally<%# container.dataitem("idCompetition") %>" name="Game<%# container.dataitem("idCompetition") %>" value="0" /> NoWinner</td>
  18.           </tr>
  19.       </ItemTemplate>
  20.       <FooterTemplate>
  21.         </table>
  22.       </FooterTemplate>
  23.     </asp:Repeater>
  24.  
and I try to get the controls in the backend with this code-behind:

Expand|Select|Wrap|Line Numbers
  1. count = 0
  2.         While count < GamesSet.Rows.Count
  3.             For Each item In GameFuture.Items
  4.                 If item.ItemType = ListItemType.Item Or item.ItemType = ListItemType.AlternatingItem Then
  5.                     temp = GamesSet.Rows(count).Item(0).ToString() 'gamenumber
  6.                     temp2 = "Game" & temp
  7.                     Game = item.FindControl(temp2)
  8.                     temp2 = "Win1" & temp
  9.                     rb1 = item.FindControl(temp2)
  10.  
  11.  
  12.                 End If
  13.                 count = count + 1
  14.             Next
  15.         End While
  16.  
The problem is that the Game and rb1 stay Nothing.....In the source when debugging I see that these fields with their ID's are there....

RadioButton rb1=(RadioButton)item.FindControl("RadioButtonID") ;
if(rb1.Checked)
then do what ever you want
Oct 25 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: kamaumalone | last post by:
I have a dropdownlist which lives inside of a repeater. The repeater accepts user input via textboxes and the aforementioned dropdownlist. The repeater accepts phone numbers and allows for an...
1
by: Mark Fox | last post by:
Hello, I have a repeater and in each itemtemplate I have a radiobuttonlist. I am attempting to figure out how on postback I could iterate through the rows displayed by the repeater and for...
2
by: Mark | last post by:
I am trying to use a Pagable Repeater with checkboxes in ASP.Net, I cannot seem to associate the checkbox with a particular database record so I lose the checked state from page-to-page. Below is...
4
by: Ryan Ternier | last post by:
Thanks for the previous help guys! I got my list box issue working, but now i'm trying to loop through all the items in my page. I want to find each listbox, once I do i strip the ID down to...
1
by: Taymorza | last post by:
All, I need some help with the ASP.NET Repeater Control. I am not a very strong ASP.NET developer. I am using the repeater control display pictures. I want to have six pictures in a row and then...
1
by: Dave | last post by:
I have a button in the same page as the repeter control, so when I click that I need to loop threw the repeater and get the value of each textbox and id Dave
2
by: Ceema M via DotNetMonster.com | last post by:
Hello all, I have a nested repeater, which displays categories(parent repeater) and corresponding subcategories(child repeater). Both repeaters have checkboxes. When I check category checkbox...
2
by: sck10 | last post by:
Hello, I am calling a stored procedure to populate a Repeater Control. What I need to do is see if a name is in the list and if not, add it to the Repeater. Is there a way to reset the...
4
by: parsifal | last post by:
Hi everyone :-) I am learning to use the Repeater control to display a list of data. Each of my list items (or rows, however you look at it) has some child items that are 1..N in length. So I'd...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.