开发者

GridView JavaScript

开发者 https://www.devze.com 2023-01-23 02:51 出处:网络
How to check whether an开发者_运维问答 ASP.NET GridView has atleast one row, using JavaScript?just wondering why count the Dom element

How to check whether an开发者_运维问答 ASP.NET GridView has atleast one row, using JavaScript?


just wondering why count the Dom element

var _count = '<%=GridView1.Rows.Count %>';
var rowcount = (_count)?_count:0;


GridView is rendered as an Html table so you just access it in javascript like

var grid = document.getElementById('<%=GridViewId.ClientID %>');
var totalrowcount = grid.rows.length;


using Jquery find the ID of your gridview

 var rowCount = $('#<%=gridview.ClientID%> tr').length;

rowCount will get the value of the total rows.If it is 1 then it contains only only headers.

0

精彩评论

暂无评论...
验证码 换一张
取 消