使用jQuery获取GridView的数据行的数量

     一个同事在群里抛出了上述的问题,另一个同事给出了答案,试了一下,还不错.贴出代码和效果图:   

 1 <html xmlns="http://www.w3.org/1999/xhtml">
 2 <head runat="server">
 3     <title></title>
 4     <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
 5     <script type="text/javascript">
 6         $(document).ready(function () {
 7             $("#btn123").click(function () {
 8                 var totalRow = $("#<%=GridView1.ClientID %> tr").length - 1;
 9                 alert(totalRow);
10             });
11         });
12     </script>
13 </head>
14 <body>
15     <form id="form1" runat="server">
16     <div>
17         <asp:GridView ID="GridView1" runat="server" Height="151px" Width="152px">
18         </asp:GridView>
19         <br/> <br/>
20         <asp:Button Width="100" Height="50" ID="btn123" Text="show" runat="server"/>
21     </div>
22     </form>
23 </body>
24 </html>
View Code

效果图:

原文地址:https://www.cnblogs.com/hshuai/p/3708979.html