你将购买记录放在数组中,然后将这个数组采用session保存起来,会更好一些。
解决方案 »
- 如何把数据传到网上,任何一台电脑都能访问
- union 联表之后如何区分数据表
- winform获取当前程序路径问题
- C#通过飞信WebService发送免费短信
- WEB页面如何触发工作流引擎?
- dllimport 调用delphi编写的dll问题 Not found the kernel or the kernel
- 做客户端管理系统用 WinForm 还是 WPF ? 请给我一个理由!
- 在.net中如何根据.dmp文件判断出该dmp文件对应的用户名和密码?
- 有关自定义控件的问题1
- Devexpress 中 gridControl 控件合并单元行问题
- 关于发布的问题!
- 为什么sql老是连不上,求救~
如果你要用httpcookies看看这个。
{
Hashtable ht = (Hashtable)Session["myCart"];
if(ht==null)
{
ht = new Hashtable();
ht.Add(TextBox1.Text,TextBox2.Text);
}
else
{
if(ht[TextBox1.Text]==null)
{
ht.Add(TextBox1.Text,TextBox2.Text);
}
else
{
ht[TextBox1.Text] = Convert.ToInt32(ht[TextBox1.Text])Convert.ToInt32(TextBox2.Text);
}
}
Session["myCart"] = ht;
Response.Write("<script>alert('"+ht[TextBox1.Text].ToString()+"');</script>");
}
也就是说下面的代码,无法在本地硬盘上建立Cookie。
请看错误在哪呢?
我把系统放置Cookie里的文件全部删除。然后跑下面的代码,发现在机器上并没有建立Cookie 请问为什么呢?private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
int BookId;
HttpCookie cookie;
if(!Page.IsPostBack)
{
if(1!=1)
{
//用户没有登陆
}
else
{
if(!Object.Equals(Request.QueryString["id"],null))
{
BookId=int.Parse(Request.QueryString["id"].ToString());
if(Object.Equals(Request.Cookies["MyCart"],null))
{
cookie = new HttpCookie("MyCart");
Response.Write("<script>alert('"+"开始新建Cookie"+"');</script>");
}
else
.......
}
}
}