Skip to content Skip to sidebar Skip to footer

Get The Corresponding Row Values For Check Box Checked Row In Grid View Using Javacsript

I have following grid with check boxes on each row, i want to get the corresponding selected row cells value when i checked the check box .. I am able to give the alert when the

Solution 1:

You can do this. It attaches a function to the checkbox change, finds the nearest tr and loops all the td

<scripttype="text/javascript">
    $(document).ready(function () {
        $('#<%= gvPRCertInfo.ClientID %> input[type="checkbox"]').change(function () {
            $(this).closest('tr').children('td').each(function () {
                alert($(this).html());
            });
        });
    });
</script>

However you have an AutoPostBack="true" in your checkbox, so everything you do in javascript is lost immediately due to a PostBack.

Solution 2:

Try this.

functioncheckForVirtual(checkBox){
    if(checkBox.checked)
    {
        var row = checkBox.parent.parent;
        row.getElementById('<%= hdnCertId.ClientID %>');// this will get the hdnCertId
        row.cell[0].getElementById('<%= hdnCertId.ClientID %>');
        alert('checked');
}

}

This might help

Post a Comment for "Get The Corresponding Row Values For Check Box Checked Row In Grid View Using Javacsript"