Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

In ASP.NET webpage i'm using repeater,

in a repater i have hiddendfields and checkBoxes.
ASP.NET
<asp:Repeater ID="rptSearchCandidates" runat="server">
                            <HeaderTemplate>
                                <table style="width: 100%;" class="table">
                                    <tr>
                                        <th><b>Code</b></th>
                                        <th><b>Center</b></th>
                                        <th>Candidate NameEN</th>
                                        <th>Candidate NameAR</th>
                                        <th>Select</th>
                                    </tr>
                            </HeaderTemplate>
                            <ItemTemplate>
                                    <tr>
                                        <td style="font-weight: bold">
                                            <%# Eval("Code") %>
                                            <asp:HiddenField ID="hdnCandidateID" runat="server" Value='<%# Eval("ID") %>' />
                                        </td>
                                        <td style="font-weight: bold">
                                            <%# Eval("Center.NameEN") %>
                                        </td>
                                        <td>
                                            <%# Eval("NameEN") %>
                                        </td>
                                        <td>
                                            <%# Eval("NameAR") %>
                                        </td>
                                        <td>
                                            <asp:CheckBox ID="chkCandidate" runat="server" />
                                        </td>
                                    </tr>
                            </ItemTemplate>
                            <FooterTemplate>
                                </table>
                            </FooterTemplate>
                        </asp:Repeater

>

What I have tried:

i want to fetch hiddenfield values where checkbox of that row in selected, using jQuery.

can any one please help me.

Thanks
Posted
Updated 2-Oct-16 19:29pm
v3

1 solution

try this

JavaScript
function beoreSave()
      {
          var selectedIds = [];
          $('[id*="chkCandidate"]').each(function (i,item) {
              if (item.checked) {
                  var val = $(item).parent().parent().find('[id*="hdnCandidateID"]').val();
                  selectedIds.push(val);
              }
          });
          alert(selectedIds.join(','));
      }
 
Share this answer
 
Comments
abdul subhan mohammed 3-Oct-16 3:13am    
thanks a lot
Karthik_Mahalingam 3-Oct-16 4:43am    
welcome asm :)
abdul subhan mohammed 3-Oct-16 10:14am    
Hi karthik,

i'm filing the repeater for update, in pageload event.

When i filled check boxes(programmatically) in c#, and then unselected some checkboxes from GUI, it is giving only ',' (comma) instead of values.

where as there are some checkboxes are checked and unchecked.

can u plz help me, how to solve this.
Karthik_Mahalingam 3-Oct-16 10:43am    
make sure the name is correct "chkCandidate"
did u do any change in UI code?
abdul subhan mohammed 4-Oct-16 1:46am    
No changes in UI code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900