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

Reading number is top 10 articles
用javascript-css实现GridView行背景色交替、点击行变色_[Asp.Net教程]
单点登录在ASP.NET上的简单实现_[Asp.Net教程]
asp.net读取磁盘文件、删除_[Asp.Net教程]
编写XHTML需要注意的问题以及和HTML的区别_[Html教程]
GridView隐藏列取值解决方案_[Asp.Net教程]
C#教程:WebResponse类使用实例
ASP.NET,MVC,Framework体验(3):表单提交_[Asp.Net教程]
.net2.0中使用SqlBulkCopy进行大批量数据迁移_[Asp.Net教程]
五个SQL,Server数据库备份与恢复必需知道并且会用的具体操作_mssql学习_编程技术
巧用Ajax和RSS做个人门户网站_[AJAX教程]
Reading number is top 10 pictures
NeedWallpaper6
A man's favorite things10
The Soviet union swimsuit exposure in the 70 year2
分手的感悟
ashlynn brooke
Take you to walk into the most true north Korea rural2
Go to the national museum2
LiXiang early youth photo
Soong ching ling's former residence1
银行20年后可能消失
Download software ranking
Twenty piece of palm leaf
Red cliff
jdk1.6 for windows
Sora aoi, the maid, students' uniforms
少妇苏霞全本
Kung fu panda - the secret of the teacher
C#与.NET技术平台实战演练
Sora aoi‘s film--Lust fan wall
变速齿轮3.26
Rio big adventure
aaa published in(发表于) 2013/12/18 7:54:37 Edit(编辑)
ASP.NET中Multi——ListBox控件编程详解_.net资料_编程技术

ASP.NET中Multi——ListBox控件编程详解_.net资料_编程技术

ASP.NET中Multi-ListBox控件编程详解_.net资料_编程技术-你的首页-uuhomepage.com
  开发一个优秀的数据绑定不是一件很容易的事情。刚开始的时候走了一些弯路,一直紧紧咬着 DataBoundControl类不放。最终失望之后冷静下来想到关于DataSource不就是一个数据集合吗?明白之后,有关数据源的问题基本上也解决了。在整个Multi-ListBox控件开发中,我认为最重要的实际上就是页面的生命周期的理解,如果您基本上理解了它的话,那么,基本上,你以后开发一款ASP.NET控件也不是一件很难的事情。我们还是简单了解开发的思路吧。下面是类的设计图(跟本文无关的方法和属性已被我隐藏)
ASP.NET中Multi-ListBox控件编程详解

  在控件的生命周期中,我们主要需要解决用户回发页面的时候保留ListBox的数据源(因为我没有采用复合控件的方式来开发)。因些,我们需要重写控件的SaveViewState, LoadViewState二个方法。

  ViewStates


1 protected override void LoadViewState(object savedState)
2 {
3 if (savedState != null)
4 {
5 Triplet triplet = (Triplet)savedState;
6 base.LoadViewState(triplet.First);
7 Reflector.InvokeMethod(this.FirstListBox.Items, "LoadViewState", new object[] { triplet.Second });
8 Reflector.InvokeMethod(this.SecondListBox.Items, "LoadViewState", new object[] { triplet.Third });
9 }
10 else
11 {
12 base.LoadViewState(null);
13 }
14 this._stateLoaded = true;
15 }
16
17 protected override object SaveViewState()
18 {
19 if (EnableViewState == false)
20 return null;
21 //启用控件视图状态
22 object x = base.SaveViewState();
23 object y = Reflector.InvokeMethod(FirstListBox.Items, "SaveViewState", null);
24 object z = Reflector.InvokeMethod(SecondListBox.Items, "SaveViewState", null);
25 if ((x == null) && (y == null) && (z == null))
26 {
27 return null;
28 }
29 return new Triplet(x, y, z);
30 }



添加到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.