gridview中Checkbox全选或全取消的js代码
来源:互联网 发布:四川医疗软件 编辑:程序博客网 时间:2024/04/28 09:36
js如下:
function CheckAll(id,GridViewID) {
//get reference of GridView control
var grid = document.getElementById("<%= GridViewID.ClientID %>");
//variable to contain the cell of the grid
if (grid.rows.length > 0) {
//loop starts from 1. rows[0] points to the header.
for (i = 1; i < grid.rows.length; i++) {
//get the reference of first column
cell = grid.rows[i].cells[0];
//loop according to the number of childNodes in the cell
for (j = 0; j < cell.childNodes.length; j++) {
//if childNode type is CheckBox
// alert(cell.childNodes[j].type);
// if (cell.childNodes[j].type == "checkbox") {
// //assign the status of the Select All checkbox to the cell checkbox within the grid
// cell.childNodes[j].checked = document.getElementById(id).checked;
// }
control=cell.childNodes[j];
for(d=0; d<3;d++) //search up to 3 levels deep
{
//if childNode type is CheckBox
if (control.type =="checkbox")
{
//assign the status of the Select All checkbox to the cell checkbox within the grid
control.checked = document.getElementById(id).checked;
break; //once you find it get out!!
}
if(control.childNodes.length>0)
control=control.childNodes[0];
}
}
}
}
}
C#代码加入
protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Text = "<input id=/"Checkbox2/" type=/"checkbox/" name=/"chkall/" onclick=/"CheckAll('Checkbox2')/"/><label></label>";
}
}
- gridview中Checkbox全选或全取消的js代码
- 一段checkbox全选或钱取消的js代码
- 关于Gridview中CheckBox全选的取消
- 比较全的JS checkbox全选、取消全选、删除功能代码
- js实现datalist中checkbox全选或取消
- 全选/取消 gridview中checkbox的功能实现
- jsp页面checkbox全选或全部取消的代码
- Checkbox 全选和取消全选的代码
- DataGrid中CheckBox的全选/取消全选
- AngularJs实现checkbox的全选、全取消
- js 的CheckBox 的全选总结 (Table或GridView中所有的CheckBox处理) j-query的处理
- asp.net gridview中添加checkbox列,用于全部选中记录或取消全选
- JS复选框checkbox:父复选框全选全取消子选框和子选框选则而父选框自动选中的代码
- JS小功能(checkbox实现全选和全取消)实例代码
- [js代码] input checkbox 全选与取消全选
- GridView控件中模板列CheckBox全选、反选、取消实现代码
- js checkbox全选和取消的事件
- GridView控件中模板列CheckBox全选、反选、取消
- hibernate
- IGMPv3向后兼容问题
- sql优化总结
- hdu1233还是畅通工程
- 每日一句
- gridview中Checkbox全选或全取消的js代码
- VC6.0中GDI+使用
- 一些linux网络API
- api_point_in_body
- SQL删除重复记录的N种方法
- 一个分号惹的祸
- Linux 常用命令
- 在ubuntu 10.10下安装 WebSphere Application Server V7.0和WebLogic10.3
- Fedora14 audacious的安装 和 Rhythmbox中文乱码解决方案