I tried this
var totalRows = $("#<%=GridView1.ClientID %> tr").length;
and it failed
when I tried
var count = $get("mygridviewclientid").rows.length
it gave the count of all the rows (th and tr)
I also made sure that the attribute ClientIDMode="Static"