views:

31

answers:

2

Hi, Please let me know how to check if any checkbox is checked in a specific column (for example first column) of the GridView control using jQuery? there are checkboxes in other columns too, but I need to check if any checkbox is checked in a specific column. thanks in advance.

+1  A: 

You could do this:

var checked = $('selectorForColumn :checkbox:checked').length > 0;

or this:

var checked = $('selectorForColumn :checkbox').is(':checked');

...which will return true if at least one checkbox in the column is checked.

Not sure what the proper selector is without seeing your markup, but if it is the first column, you would do something like this:

$('table > tbody > tr > td:first-child :checkbox')
patrick dw
A: 

thanks for the reply. solved it myself with help from the following link

if ($("#<%=GridView1.ClientID %> >tbody >tr >td:first-child > input[type=checkbox]:checked").length > 0) {}

http://www.codedigest.com/CodeDigest/63-Check-All-Checkboxes-in-a-Particular-Column-in-GridView-using-JQuery-.aspx

RKP
Yeah, that's the same as my first solution.
patrick dw