0

I have a gridview with a template field of check boxes.

I have my rows color coded in BLUE color in the gridview based on a database value on page load.

Now I want a button on the page to loop through the gridview and select the the checkbox for the rows that are in BLUE Color without a post back.

any help would be appreciated.

thanks.

2 Answers 2

1

Loop through gridview rows on client-side javascript

var GridviewRows = $("#<%=gvbooksdetails.ClientID%> tr").length;
var rowlenght = GridviewRows - 1;
for (var i = 0; i < rowlenght; i++)
    {                                                  
    var Aname = document.getElementById("MainContent_gvbooksdetails_lblgvauthorname_" +[i]+"").innerHTML;
    var Bname = document.getElementById("MainContent_gvbooksdetails_lblgvbookname_" +[i]+ "").innerHTML;
    var BType = document.getElementById("MainContent_gvbooksdetails_lblgvbooktype_" +[i]+ "").innerHTML;
    var Pubilication = document.getElementById("MainContent_gvbooksdetails_lblgvPublisher_" + [i] + "").innerHTML;
    var Bid = document.getElementById("MainContent_gvbooksdetails_hiddenid_"+[i]+"").value;
    }

Instead of foreach we can use this method.

Sign up to request clarification or add additional context in comments.

Comments

0
$('#mygrid tr.blueClass input[type="checkbox"]').each(
     function() { 
         this.checked = true;
 });

Assuming mygrid is the name of your gridview, and each blue row has a class called blueClass

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.