how to count the number of lines in gridview in javascript?


As the question says, i wish to count the number of rows in gridview via JS. I am doing the way it is done here but that is not coming up correctly.

I have also tried different ways as:

 1. var rowscount = document.getElementByID('<%=Gridview1.ClientID%>').rows.length;
 2. var rowscount = document.getElementByID("<%=Gridview1.ClientID%>").rows.length;
 3. var rowscount = document.getElementByID('<%#Gridview1.ClientID%>').rows.length;
 4. var rowscount = document.getElementByID("<%#Gridview1.ClientID%>").rows.length;
 5. var rowscount = document.getElementByID("Gridview1.ClientID").rows.length;
 6. var rowscount = document.getElementByID("Gridview1").rows.length;

UPDATE : Forgot to Mention: My gridview is inside updatepanel. Would that make any difference? What is the right statement?

If you want to get the number of rows from the server one way would be to use:

var rowsCount = <%=GridView1.Rows.Count %>

It is also possible to send the data to JavaScript from codebehind.