How to find LinkButton in GridView using JavaScript or JQuery?

advertisements

I have one GridView "gvDetail" which has 30 columns(include both Template and BoundField).

In that columns, I have One CheckBox "chkSelect" in the Second Column. And One LinkButton "lnkQC" in the 22nd Column.

I want to Enable the LinkButton when I check the CheckBox in the GridView. And also I want to Disable the LinkButton when I uncheck the CheckBox.

How to achieve this using JavaScript or JQuery? Please I need all your suggestions...


Your LinkButton renders to simple anchor. The code will looks like this. If you have some links inside the table you will need to specify some css class to this linkbutton and change selector in this js.

$(document).ready(function() {
    $('#grid-table-id input:checkbox').change(function() {
        var linkDisableHandler = function(e) {
                                       e.preventDefault();
                                       return false;
                                 };

        if ($(this).is(':checked')) {
            $(this).closest('tr')
                   .find('a')
                   .removeClass('disabled')
                   .unbind('click', linkDisableHandler);
        }
        else {
            $(this).closest('tr')
                   .find('a')
                   .addClass('disabled')
                   .bind('click', linkDisableHandler);;
        }
    });
});

Now, I just changing the css class for link, but to disable link you need to take a look on this post: jQuery disable a link