购物车购物
if (Session["Pro"] == null)
{
DataTable dt = new DataTable();
dt.Columns.Add("_id", typeof(int));//商品id
dt.Columns.Add("_title", typeof(string));//商品名
dt.Columns.Add("_color", typeof(string));//商品颜色
dt.Columns.Add("_sizename", typeof(String));//商品尺码
dt.Columns.Add("_catename", typeof(String));//商品类别
dt.Columns.Add("_imageurl", typeof(String));//商品类别
DataRow dr = dt.NewRow();
dr["_id"] = _id.Text;
dr["_title"] = title_l.Text;
dr["_color"] = d_color.Text;
dr["_sizename"] = _SizeOne.Text;
dr["_catename"] = _Cate.Text;
dr["_imageurl"] = Image_1.ImageUrl;
dt.Rows.Add(dr);
Session["Pro"] = dt;
Response.Redirect("shoplist.aspx");
Response.End();
}
else
{
//datatable是在第一条数据上累加的
DataTable dt = Session["Pro"] as DataTable;
DataRow dr = dt.NewRow();
dr["_id"] = _id.Text;
dr["_title"] = title_l.Text;
dr["_color"] = d_color.Text;
dr["_sizename"] = _SizeOne.Text;
dr["_catename"] = _Cate.Text;
dr["_imageurl"] = Image_1.ImageUrl;
dt.Rows.Add(dr);
Session["Pro"] = dt;
Response.Redirect("shoplist.aspx");
Response.End();
}