Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys,

I have an asp.net page, in which i have a repeater, in this repeater i'm binding 86 rows of data, and i have one checkbox in each row.

if the user checked the check box then it will save those rows data only.

i'm able find out the checkbox, jquery
                $("#tBodyVT .trvtRow").each(function () {
                    var chk = $(this).find(".chk");
});


but not able to check, is checked or not?

What I have tried:

if(!$(this).is(':checked'))

if ($(this).is(':not(:checked)'))

if ($(this).attr('checked') == false)

var checked = $(this).is(':checked');
            if (checked) {
                alert('checked');
            } else {
                alert('unchecked');
            }


i tried all these code, but didn't get.

Please guys help me.

Thanks
Posted
Updated 21-Mar-16 22:08pm
v2
Comments
Kornfeld Eliyahu Peter 20-Mar-16 6:39am    
What about chk.checked?
abdul subhan mohammed 20-Mar-16 7:28am    
not working
[no name] 20-Mar-16 7:25am    
Provide relevant code of your repeater control structure. And tell us what you want exactly? Improve your question.
abdul subhan mohammed 20-Mar-16 7:29am    
i have a repeater, in each row i have checkbox, i found the checkbox using its class in jquery and not able to check, whether this check box is checked or not.
hope u got me. Thanks
[no name] 20-Mar-16 7:36am    
Try like below:

$("#tBodyVT .trvtRow").each(function () {

if($(this).find(".chk").prop('checked'))
{
alert('checked');
}
else
{
alert(unchecked);
}
});

You haven't posted the relevant parts of the repeater markup so I can only guess it is like the below, and if so this should work, if not you'll need to update your question to include the markup as we can't give you a solution if we don't know your html structure.

ASP.NET
<asp:Repeater ID="myRepeater" runat="server">
    <HeaderTemplate>
        <table id="myTable">
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
            <td><asp:CheckBox ID="myCheckbox" CssClass="chk" runat="server" /></td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>

<button onclick="test();">test</button>

<script type="text/javascript">
    function test() {
        var selected = $("#myTable span.chk :checked");
        alert(selected.length);
    }
</script>
 
Share this answer
 
Thanks all,

i tired this n i got it.

alert($(this).find(".chk").val() ? true : false);
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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