make the Hashtable a member of your Form class
class YourForm : Form
{
Hashtable hstable = new Hashtable();
...void buttonclick(...)
{
Random r=new Random();
double d=r.NextDouble();
int i=(int)(d*1220);
hstable.Add(i.ToString(),r.NextDouble().ToString());
}
class YourForm : Form
{
Hashtable hstable = new Hashtable();
...void buttonclick(...)
{
Random r=new Random();
double d=r.NextDouble();
int i=(int)(d*1220);
hstable.Add(i.ToString(),r.NextDouble().ToString());
}
解决方案 »
- AES加密 密钥长度问题
- 在asp.net(C#)开发网站中如何在你注册成功后会发送一份电子邮件到你的邮箱里,然后你进入你的邮箱会看到一个超链接的地址,当你点击这个超链接后,完成注册验证
- 如何读取本地xml文件导入服务器?
- asp.net 网站怎样防机器注册
- 请问如何实现 检查 上传的附件 是否 jpg 或者 bmp 的格式,如果是图片如何 获得 图片的 宽度和高度 ?????? 急 !!!
- 关于DataGrid的问题~!
- 如何更新框架網頁中一頁面的值
- 急招----.NET程序员
- asp.net/C# 页面跳转问题.求技术型指点
- 各位帮忙!谢谢了
- 急、急、急!!分页问题!!!
- 做一个asp.net的开发环境调查,见者有分!!!!
public class p21 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.DataList MyDataList;
protected Hashtable hstable = new Hashtable();
…………
private void Button1_Click(object sender, System.EventArgs e)
{
Random r=new Random();
double d=r.NextDouble();
int i=(int)(d*2000);
hstable.Add(i.ToString(),r.NextDouble().ToString());
MyDataList.DataSource = hstable;
MyDataList.DataBind();
}
…………
}
是这样吗?这该怎么做?
在Page_Load中加入:
if (ViewState["Hashtable"] != ull)
{
hstable = (Hashtable)ViewState["Hashtable"];
}
在Button1_Click的最后加上:
ViewState["Hashtable"] = hstable;
看:
…………
protected Hashtable myhstable =new Hashtable();
void Page_Load(object sender, System.EventArgs e){
if (Session["Hashtable"] != null)
{
myhstable = (Hashtable)Session["Hashtable"];
}}
……
void Button1_Click(……){
string reqid=Request.QueryString["cr_id"].ToString();
Random r=new Random();
double d=r.NextDouble();
int i=(int)(d*2000);
myhstable.Add(i.ToString(),reqid);
Session["Hashtable"] = myhstable;
DataList1.DataBind();
Response.Redirect("WebForm1.aspx");}
??
在Button1_Click中转向WebForm1.aspx,那在WebForm1.aspx中的处理呢?
…………