惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - xixi8820

输入框验证输入数字的js 关于VS2005中GridView的自定义分页,单选、多选、排序、自增列的简单应用(转载的) 使用t-sql从身份证号中提取生日(转自别人,个人学习收藏用) 一个最简单的登录例子 js中setTimeout与setInterval的区别 js将html中的内容导出word、或者excel文件的方法 javascript 获得指定日期的临近日期的方法 asp.net 2.0 生成验证码 - xixi8820 在Asp.Net中应用DataFormatString ASP.NET中App_Code,App_Data等文件夹的作用 javascript 客户端验证 - xixi8820 在DataGrid中模版列显示图片 - xixi8820 上传图片 - xixi8820 页面取物理路径和几种获取asp.net应用程序的路径 模式窗口关闭,并刷新父窗口的方法 用window.location.href实现刷新另个框架页面 听说是个高效的分页存储过程,可以轻松应对百万数据(转) keycode 值 DataGrid点击删除按钮弹出对话框的问题
跨页面实现多选
xixi8820 · 2007-11-23 · via 博客园 - xixi8820

js:

 1function selectAllChk(chk)
 2        {
 3            //全选
 4            var obj = document.getElementsByTagName('input');
 5            for(var i = 0;i < obj.length;i++)
 6            {
 7                if (obj[i].type == 'checkbox' && obj[i].id.indexOf('chkID') > -1)
 8                {
 9                    obj[i].checked = chk;
10                    
11                    //全选赋值            
12                    if(obj[i].checked)//判断是否选中
13                    {
14                        if(Form2.txtIDs.value.indexOf(obj[i].value) > -1)//如果选择中,避免单选后再全选,造成ID重复
15                        {
16                            continue;
17                        }
18                        else
19                        {
20                                Form2.txtIDs.value += "," + obj[i].value; 
21                        }
22            
23                    }
24                    else
25                    {
26                        Form2.txtIDs.value = Form2.txtIDs.value.replace("," + obj[i].value,""); 
27                    }
28                }
29            }
30        }

 1function AddRemoveValues(oChk)
 2        {
 3            //单个选择赋值
 4            if(oChk.checked)
 5            {
 6                Form2.txtIDs.value += "," + oChk.value; 
 7            }
 8            else
 9            {
10                Form2.txtIDs.value = Form2.txtIDs.value.replace("," + oChk.value,""); 
11            }
12        }

 1<script type="text/javascript">
 2            //重新显示所选择的项目
 3            var obj = document.getElementsByTagName('input');
 4            for(var i = 0;i < obj.length;i++)
 5            {
 6                if (obj[i].type == 'checkbox' && obj[i].id.indexOf('chkID') > -1)
 7                {
 8                    if(Form2.txtIDs.value.indexOf(obj[i].value) >= 0)
 9                    {    
10                        obj[i].checked = true;
11                    }

12                    else
13                    {
14                        obj[i].checked = false;
15                    }

16                }

17            }

18            
</script>

隐藏控件用来保存ID:

1<input id="txtIDs" type="hidden" name="txtIDs" runat="server">


DataGrid 控件中的模版列:

 1<asp:TemplateColumn>
 2    <HeaderStyle Wrap="False" HorizontalAlign="Center" Width="5%"></HeaderStyle>
 3    <ItemStyle HorizontalAlign="Center"></ItemStyle>
 4    <HeaderTemplate>
 5<INPUT id="chkSelectAll" onclick="selectAllChk(this.checked);" type="checkbox" value=""
 6 name="chkID" runat="server">
 7    </HeaderTemplate>
 8    <ItemTemplate>
 9<INPUT id="chkID" onclick="AddRemoveValues(this);" type="checkbox" value='<%# DataBinder.Eval(Container.DataItem, "PI_ID") %>'  name="chkID" >
10    </ItemTemplate>
11</asp:TemplateColumn>

还可以参考孟宪会的跨页面实现多选