i am trying to loop through a gridview using jquery, the code i am using is
$('#<%=gridview1.clientid%> tbody tr').not(':first,:last')
.each(function(){
gridrows ++;
});
i would like to eliminate the first and 开发者_如何学Golast rows which are obviously the header and footer , i tried this code but seems that it is not working, it is returning the count of gridview rows. any ideas.
Two possible things to consider:
(1) Try to avoid mixing your server code in your jquery. Just use the gridview's ID property $('#myGridView') instead of getting it through the brackets. (Maybe you weren't trying to do that, though.)
(2) Have a read of Rick Strahl's post on this topic. http://www.west-wind.com/weblog/posts/822827.aspx
I believe you'll find it covers the problem you're encountering now.
If you're using <tbody>
, why not use <thead>
for header and <tfoot>
for footer?
<table>
<thead><tr>..</tr></thead>
<tbody><tr>..</tr></tbody>
<tfoot><tr>..</tr></tfoot>
</table>
?
Then you can lose the .not()
part. Also, are you sure that that ASP.net code returns existing id? :)
精彩评论