Click here to Skip to main content
15,891,739 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to check the values of four checkboxes in a given GridView row using jQuery. I've tried the following and it is not working:

Here's my jQuery:
Java
function isItOkay() {
$('table[id$="gv_Detail"] tbody tr').each(function () {
  var $kdConnect = $(this).find("input:checkbox:checked");
  var icanConnect = $(this).find("input[name$='chkConnect']");
  var icantConnect = $(this).find('input[type="checkbox"][name$="chkConnect"]:checked');
  var icanUnify = $(this).find('input[type="checkbox"][name$="chkUnify"]:checked');
  var icanPrimary = $(this).find('input[type="checkbox"][name$="chkPrimary"]:checked');
  var icanSecondary = $(this).find('input[type="checkbox"][name$="chkSecondary"]:checked');
  var iConnect = $(this).find("#chkConnect").is(':checked');
  var iUnify = $(this).find("#chkUnify").prop('checked');
  var iPrimary = $(this).find("#chkPrimary").prop('checked');
  var iSecondary = $(this).find("#chkSecondary").is(':checked');
  alert("value of icanConnect - " + icanConnect.val() + "/r/n" + "value of icanUnify - " + icanUnify + "/r/n" + "value of icanPrimary - " + icanPrimary + "/r/n" + "value of icanSecondary - " + icanSecondary);
  });
}

Here's the markup for my GridView:
ASP.NET
<asp:GridView ID="gv_Detail" runat="server" BackColor="White" Caption="Staff Name 
    Here" CssClass="tableXBase2" 
    BorderColor="#3366CC" BorderStyle="Ridge" BorderWidth="1px" CellPadding="4"  
    HorizontalAlign= "Center" AutoGenerateColumns="False" GridLines="None" 
    OnRowDataBound="gv_KLDetail_RowDataBound"
    EmptyDataText="No Details for this Item" CaptionAlign="Top" Visible="false">
    <columns>
        <asp:BoundField DataField="WFCenterName" HeaderText="Workforce Center" 
            ItemStyle-Wrap="false" />
            <asp:TemplateField HeaderText="Connect" HeaderStyle-
                HorizontalAlign="Center">
                <itemtemplate>
                 <asp:checkBox ID="chkConnect" runat="server" AutoPostBack="false" 
                  Checked='<%# Convert.ToBoolean(Convert.ToInt16(Eval("Connect"))) 
                  %>' Enabled='true' Text=''                          
                  OnCheckedChanged="chkConnect_OnCheckedChanged">
                 
               </itemtemplate>
            
            <asp:TemplateField HeaderText="Unify" HeaderStyle-
                HorizontalAlign="Center">
                <itemtemplate>
                  <asp:checkBox ID="chkUnify" runat="server" AutoPostBack="false" 
                   Checked='<%# Convert.ToBoolean(Convert.ToInt16(Eval("Unify"))) %>'
                   Enabled='true' Text=''
                   OnCheckedChanged="chkConnect_OnCheckedChanged">
                  
                </itemtemplate>
            
            <asp:TemplateField HeaderText="Primary" HeaderStyle-
                HorizontalAlign="Center">
                <itemtemplate>
                 <asp:checkBox ID="chkPrimary" runat="server" AutoPostBack="false" 
                 Checked='<%# Convert.ToBoolean(Convert.ToInt16(Eval("Primary"))) %>'
                 Enabled='true' Text=''
                 OnCheckedChanged="chkConnect_OnCheckedChanged">
                
              </itemtemplate>
            
            <asp:TemplateField HeaderText="Secondary" HeaderStyle-HorizontalAlign="Center">
                <itemtemplate>
                   <asp:checkBox ID="chkSecondary" runat="server" 
                    AutoPostBack="false"                 
                    Checked='<%# 
                    Convert.ToBoolean(Convert.ToInt16(Eval("Secondary"))) %>'
                    Enabled='true' Text=''
                    OnCheckedChanged="chkConnect_OnCheckedChanged">
                   
                </itemtemplate>
            
     </columns>
     <footerstyle backcolor="#99CCCC" forecolor="#003399" />
          <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
     <pagerstyle backcolor="#99CCCC" forecolor="#003399" horizontalalign="Left" />
     <rowstyle backcolor="White" forecolor="#003399" />
Posted
Updated 6-Nov-14 8:59am
v2
Comments
Pradip R 17-Nov-14 9:30am    
Can you post your rendered HTML? so that I can identify the error.

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