首页 > 其他 > 详细

使用ViewState[""]传递Hashtable的值

时间:2016-03-26 20:23:35      阅读:225      评论:0      收藏:0      [点我收藏+]

//首先定义
Hashtable myHach = new Hashtable();

//添加键值到Hashtable中
myHash.Add("ServiceType1", "值");

//例:
myHash.Add("Account1", this.txtAccount1.Text.Trim());

//把Hashtable放入ViewState[""]里
ViewState["condition"] = myHash;

//取得Hashtable的值
Hashtable ht = (Hashtable)ViewState["condition"];

//判断Hashtable中是否存在对应键
if(ht.ContainsKey("ServiceType1"))

//如果存在就把值赋给字符串
string ServiceType1 = ht["ServiceType1"].ToString();

使用ViewState[""]传递Hashtable的值

原文:http://www.cnblogs.com/azhou/p/5323783.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!