0

In asp.net I am using repeator having checkbox as childnode which is dynamically filled by database. I need to check atleast one checkbox using jquery and display message.how to pls anybody help me.

My repeator code

  <asp:Repeater ID="id_repSearch" runat="server">
     <HeaderTemplate>
        <table style="border: 1px solid #465c71;" cellpadding="5" width="100%">
           <tr style="background-color: #465c71; color: White" align="center">
               <td width="20%" align="center">Firstname</td>
               <td width="20%" align="center">Lastname</td>
               <td width="40%" align="center">Emailid</td>
               <td width="35%" align="center">Mobileno</td>
           </tr>
         </table>
      </HeaderTemplate>
      <ItemTemplate>
         <table width="100%">
           <tr style="background-color: FFECD8">
               <td><asp:CheckBox ID="id_chkSearch" runat="server" /></td>
               <td width="20%" align="left">
                  <%# DataBinder.Eval(Container.DataItem, "c_first_name") %></td>
               <td width="20%" align="left">
                  <%# DataBinder.Eval(Container.DataItem, "c_last_name") %></td>
               <td width="40%" align="left">
                  <%# DataBinder.Eval(Container.DataItem, "c_email_id") %></td>
               <td width="20%" align="left">
                  <%# DataBinder.Eval(Container.DataItem, "c_mobile_phone") %></td>
           </tr>
           <asp:HiddenField ID="hiddenuserid" runat="server" Value='<%#Eval("n_user_id") %>' />
           <asp:HiddenField ID="hiddenemail" runat="server" Value='<%#Eval("c_email_id") %>' />
           <asp:HiddenField ID="hiddenname" runat="server" Value='<%#Eval("c_first_name") %>' />
       </ItemTemplate>
       <SeparatorTemplate>
            <tr>
               <td>
                   <hr />
               </td>
            </tr>
        </SeparatorTemplate>
  </asp:Repeater>
2
  • what do you want to check, please explain in detail Commented Nov 19, 2012 at 12:26
  • @rahul i need to check atleast one checkbox in repeator Commented Nov 19, 2012 at 12:27

1 Answer 1

1

Simpliest way would be to place a CssClass attrtibute with some unique value into all those checkboxes, and than use a jQuery selector to check if any is selected

.....
<ItemTemplate>
    <tr style="background-color: FFECD8">
    <td>
        <asp:CheckBox ID="id_chkSearch" runat="server" CssClass="i_am_unique_class_name"/>
    </td>
 .....

And jQuery:

$('.i_am_unique_class_name:checked').length //gives you the number of selected checkboxes with attached class

See CssClass, .length and :checked manual pages for details.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.