All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
visual c++中虚基类的用法
asp.net2.0如何加密数据库联接字符串_[Asp.Net教程]
防网站登陆被破解的简单方法_[Asp.Net教程]
Vista安装.NET,2.0开发环境注意事项_[Asp.Net教程]
《Effective,C#》:区别四个判等函数_[Asp.Net教程]
SQL SERVER 和EXCEL的数据导入导出_[SQL Server教程]
delphi映像内存的操作
结合泛型与模板的STL.NET探索_.net资料_编程技术
用GridView编辑更新独立的单元格_[Asp.Net教程]
SQL中的时间计算语句_[SQL,Server教程]
Reading number is top 10 pictures
The girl of like self-time
陪睡门马睿菈自曝写真 称首拍大尺度照片1
The real super beauty5
The world's top ten most beautiful railway station2
初五接财神啦!五路财神齐来到
The real super beauty12
哥斯达黎加的门将是如何练成的
Ashlynn Brooke photograph of a group3
Sora aoi possession of boudoir2
你是左脑型还是右脑型
Download software ranking
I for your crazy
Be there or be square
C++教程第四版
WebService在.NET中的实战应用教学视频 → 第2集
Adobe Flash Player(IE) 10.0.32.18 浏览器专用的FLASH插件
Boxer vs Yellow4
Tram sex maniac 2 (H) rar bag15
Proficient in JavaScript
apache-tomcat-6.0.33
圣殿祭司的ASP.NET.2.0.开发详解-使用C#
delv published in(发表于) 2014/1/10 6:30:36 Edit(编辑)
借助HiddenText,确定CheckBoxList当前的操作类型及点击的CheckBox_[Asp.Net教程]

借助HiddenText,确定CheckBoxList当前的操作类型及点击的CheckBox_[Asp.Net教程]

借助HiddenText 确定CheckBoxList当前的操作类型及点击的CheckBox_[Asp.Net教程]

本次示例主要是解决
CheckBoxList这样的List控件
在引发SelectedIndexChanged事件时
本身不能直接得到当前的操作Item
以及是哪种操作类型 选中? 还是 取消选中?
-----------
示例代码如下:


1protected void Page_Load(object sender, EventArgs e)
2 {
3 if (!IsPostBack)
4 {
5 //绑定CheckBoxList操作
6 this.hidtxt_CheckBoxSelectValue.Value = "";//第一次绑定完CheckBoxList
7 }
8 }
9
10 protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
11 {
12 //hidtxt_CheckBoxSelectValue 存储的是上次的点选值
13 //如果上次是Page_Load 则hidtxt_CheckBoxSelectValue为空
14 string sOld = this.hidtxt_CheckBoxSelectValue.Value.Trim();
15
16 for (int i = 0; i < CheckBoxList1.Items.Count; i++)
17 {
18 //第一种情况
19 //原来没有选中 当前却选中
20 //则本次点击操作是:选中 并且点选的是这一个Item
21 if (CheckBoxList1.Items[i].Selected)
22 {
23 if (!sOld.Contains(CheckBoxList1.Items[i].Value.Trim() + ","))
24 {
25 //进行相关处理
26 Response.Write("本次是选中操作,操作的CheckBox的Text值是" + CheckBoxList1.Items[i].Text + "其Value值是" + CheckBoxList1.Items[i].Value);
27 i = CheckBoxList1.Items.Count ;
28 }
29 }
30 else
31 {
32 //第二种情况
33 //原来有选中 当前却没选中
34 //则本次点击操作是:取消选中 并且点选的是这一个Item
35 if (sOld.Contains(CheckBoxList1.Items[i].Value.Trim() + ","))
36 {
37 //进行相关处理
38 Response.Write("本次是取消选中操作,操作的CheckBox的Text值是" + CheckBoxList1.Items[i].Text + "其Value值是" + CheckBoxList1.Items[i].Value);
39 i = CheckBoxList1.Items.Count;
40 }
41 }
42 }
43
44 //保存这次的所有选中的值
45 string sNew = "";
46 foreach (ListItem item in CheckBoxList1.Items)
47 {
48 if (item.Selected)
49 sNew += " " + item.Value.Trim() + ",";
50 }
51 this.hidtxt_CheckBoxSelectValue.Value = sNew;//为下一次的比较做准备
52 }

http://www.cnblogs.com/freeliver54/archive/2007/01/11/617988.html







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.