Reputation: 16322
how do i know from the client side that how many rows are there for gridiview or listview except header row.
Upvotes: 1
Views: 1514
Reputation: 14610
Every component has to generate HTML. So once you have those elements, you can easily count them like anything else.
Let's say, that your listview generates li elements with class 'a'. Then you can do:
$('.a').length; // returns count of elements with class 'a'
Edit: You don't even need jQuery for this, you can use pure javascript solution (example).
var table = document.getElementById("abc");
var rows= table.getElementsByTagName('tr');
alert(rows.length)
for following markup:
<table id="abc">
<tr><td>abc</td></tr>
<tr><td>abc</td></tr>
<tr><td>abc</td></tr>
<tr><td>abc</td></tr>
<tr><td>abc</td></tr>
</table>
Upvotes: 1
Reputation: 18354
Like this:
var number_of_rows = $("#<%=GridView1.ClientID %> tr").size();
Upvotes: 2