Try this ....:)
DataTable dt =
GridView1.DataSource = dt;
GridView1.DataBind();
you can take a hiddenfield html control in your page and can assign its value when you bind your grid as
HiddenField1.value = GridView1.Rows.Count.ToString();
In your javascript you can get its value as
var count = document.getElementById('HiddenField1');
alert(count.value)