如何计算行数在GridView控件在JavaScript? [英] how to count number of rows in gridview in javascript?
问题描述
由于这个问题说,我希望通过JS来计数的GridView的行数。我做的是做的方式<一个href=\"http://stackoverflow.com/questions/1763641/asp-net-gridview-row-count-using-javascript\">here但就是不来正确。
As the question says, i wish to count the number of rows in gridview via JS. I am doing the way it is done here but that is not coming up correctly.
我也尝试不同的方式:
1. var rowscount = document.getElementByID('<%=Gridview1.ClientID%>').rows.length;
2. var rowscount = document.getElementByID("<%=Gridview1.ClientID%>").rows.length;
3. var rowscount = document.getElementByID('<%#Gridview1.ClientID%>').rows.length;
4. var rowscount = document.getElementByID("<%#Gridview1.ClientID%>").rows.length;
5. var rowscount = document.getElementByID("Gridview1.ClientID").rows.length;
6. var rowscount = document.getElementByID("Gridview1").rows.length;
更新:忘了提:我的gridview的是里面的UpdatePanel。请问这有什么区别?
什么是正确的说法?
UPDATE : Forgot to Mention: My gridview is inside updatepanel. Would that make any difference? What is the right statement?
推荐答案
找到了原因:由于电网是包含在内容页中,JavaScript必须被列入表单标签。它运行良好!感谢所有的投入!
Found the reason: Because the grid is included in content page, the javascript had to be included under form tag. It runs well! Thanks all for inputs!!
这篇关于如何计算行数在GridView控件在JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!