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

推荐订阅源

WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
B
Blog
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Jina AI
Jina AI
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
L
LangChain Blog
M
MIT News - Artificial intelligence
Blog — PlanetScale
Blog — PlanetScale
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell
Y
Y Combinator Blog
F
Fortinet All Blogs
H
Help Net Security
B
Blog RSS Feed
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题

博客园 - 龚振

T4 模板编辑。 MVC 表单验证的几种方式: Login failed for user 'IIS APPPOOL\ASP.NET v4.0'. - 龚振 Keycode对照表 使用多字节字符集 syslink 不显示 Windows下JSP开发环境的配置 javascript 大括号,圆括号 清空数据库日志 数据库还原错误 (with move) 打开visual studio 智能感知(intellisense) for Unity Application Blocks (翻译) firefox ie DOM 级兼容性(一) ie ,firefox 兼容性,收集。。。。。 IE6.0、IE7.0 与 FireFox 收集,总是忘,还是收集了,以后总结下 web 版 ftp 数据库迁移可能遇到的问题 将物理内存制作为虚拟硬盘,提高系统速度 NET设计模式总结 关于Web服务器时间格式问题 关于Gridview templateField 无法 sort
自定义控件状态保存
龚振 · 2008-06-12 · via 博客园 - 龚振

自定义控件状态保存

Posted on 2008-06-12 13:51  龚振  阅读(263)  评论(0)    收藏  举报

protected void Page_Load(object sender, EventArgs e)
  {
  CheckBoxList chk = new CheckBoxList();
  form1.Controls.Add(chk);
  if (!IsPostBack)
  {
  chk.Items.Add("Hello");
  }
  }
  或者:
  protected void Page_Load(object sender, EventArgs e)
  {
  CheckBoxList chk = new CheckBoxList();
  (chk.Items as IStateManager).TrackViewState();
  if (!IsPostBack)
  {
  chk.Items.Add("Hello");
  }
  form1.Controls.Add(chk);
  }