【发布时间】:2009-01-14 19:08:30
【问题描述】:
我想立即更新一个状态行,指示在 asp.net gridview 的所有页面中选中的复选框的数量。现在我只能计算在当前 gridview 页面上选中的复选框的数量。
这是我的代码:
$(document).ready(initAll);
function initAll(){
countChecked();
$(".activeBoxes").click(countChecked);
}
function countChecked() {
var n = $(".activeBoxes input:checked").length;
$("#checkboxStatus").text(n + (n == 1 ? " vehicle is" : " vehicles are") + " selected on this page. ");
if( n == 0){
$(".activateButton").hide();
$("#checkboxStatus").hide();
}else{
$("#checkboxStatus").show();
$(".activateButton").show();
}
}
【问题讨论】:
-
据我所知,只有页面上可见的元素实际上在标记中,因此在 DOM 中,因此您必须大量解析视图状态
-
我有从列表中删除未选中框的代码。我也可以包含该代码,但我的问题是关于计算网格视图所有页面中的复选框并立即更新状态而无需重新加载页面。
标签: asp.net jquery gridview checkbox