200分都没有,最后20了,以后给大家补上..麻烦大家帮我看一下这个问题. 小弟现在在做一购物系统.1.没有会员系统,怎么连续购物?2.就是在结算的时,怎么去实现购物车里面的更新,等等,里面的数据都放在那里???望那位大哥,可以帮助我一下.十分感谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 那是到seesion里面还是cookie里面还是? private void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack) { BindGrid(); } // 在此处放置用户代码以初始化页面 } private void BindGrid() { SqlDataAdapter da=new SqlDataAdapter("select * from products",@"server=ITBU;uid=sa;pwd=;database=ywtable"); DataSet ds=new DataSet(); da.Fill(ds,"products"); DataGrid1.DataSource=ds; DataGrid1.DataBind(); } public int Add(CShoppingCartItem item) { ArrayList arr; if(HttpContext.Current.Session["mycart"]!=null) { arr=(ArrayList)HttpContext.Current.Session["mycart"]; } else { arr=new ArrayList(); HttpContext.Current.Session["mycart"]=arr; } arr.Add(item); return 0; } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand); this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged); this.button1.Click += new System.EventHandler(this.button1_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e) { } private void button1_Click(object sender, System.EventArgs e) { Response.Redirect("cart.aspx"); } private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { CShoppingCartItem cart=new CShoppingCartItem(int.Parse(e.Item.Cells[0].Text),e.Item.Cells[1].Text,decimal.Parse(e.Item.Cells[2].Text),int1); Add(cart); BindGrid(); } public class CShoppingCartItem { private int intProductID; private string strProductName; private decimal decUnitPrice; private int intQuantity; public CShoppingCartItem(int intProductID,string strProductName,decimal decUnitPrice,int intQuantity) { ProductID = intProductID; ProductName = strProductName; UnitPrice = decUnitPrice; intQuantity = Quantity; } public int ProductID { get { return intProductID; } set { intProductID=value; } } public string ProductName { get { return strProductName; } set { strProductName=value; } } public decimal UnitPrice { get { return decUnitPrice; } set { decUnitPrice=value; } } public int Quantity { get { return intQuantity; } set { intQuantity=value; } } } private void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack) { FillCartFromSession(); } // 在此处放置用户代码以初始化页面 } public int Remove(CShoppingCartItem item) { ArrayList items=(ArrayList)HttpContext.Current.Session["mycart"]; for(int i=0;i<items.Count;i++) { if(((CShoppingCartItem)items[i]).ProductID==item.ProductID) { items.RemoveAt(i); break; } } return 0; } public System.Collections.ArrayList GetItems() { return (ArrayList)HttpContext.Current.Session["mycart"]; } private void FillCartFromSession() { CShoppingCartItem AllItem = null; ArrayList AllList = GetItems(); DataGrid1.DataSource=AllList; DataGrid1.DataBind(); } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e){ // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e);} /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent(){ this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand); this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged); this.Button1.Click += new System.EventHandler(this.Button1_Click); this.Button2.Click += new System.EventHandler(this.Button2_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void Button1_Click(object sender, System.EventArgs e) { Response.Redirect("WebForm1.aspx"); } private void Button2_Click(object sender, System.EventArgs e) { //now you can iterate through cookies collection //and DataGrid and get details of all items //then add your code here to insert into database } private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { CShoppingCartItem cart=new CShoppingCartItem(int.Parse(e.Item.Cells[0].Text),e.Item.Cells[1].Text,decimal.Parse(e.Item.Cells[2].Text),int.Parse(e.Item.Cells[3].Text)); Remove(cart); FillCartFromSession();这是存到SESSION的,我也是新手,借鉴别人的 把DataSet保存到Session里。或者你建个数据集DataSet.xsd。当你要更新购物车时重新绑定一下就行了。 Ajax 页面从后台取数据 帮忙看看 存取过程是否有问题 我怎么给查询条件呢 一超简单网站。外包。急 请教个配置Word的DCOM权限的问题 如何隐藏行 为什么邮件发不出去? GridView编辑列遇到的问题…… ~~~~~~~~~~这样的功能如何实现~~~~~~~~~~~~~~~~~ 关于DataList无法在页面中显示的问题(请高手指教)? 服务端接收数据问题求教 在GridView绑定事件里面如何得到绑定控件的id?--------100分---急!!!! 求一个日程管理控件
{
if(!Page.IsPostBack)
{
BindGrid();
}
// 在此处放置用户代码以初始化页面
}
private void BindGrid()
{
SqlDataAdapter da=new SqlDataAdapter("select * from products",@"server=ITBU;uid=sa;pwd=;database=ywtable");
DataSet ds=new DataSet();
da.Fill(ds,"products"); DataGrid1.DataSource=ds;
DataGrid1.DataBind();
}
public int Add(CShoppingCartItem item)
{
ArrayList arr;
if(HttpContext.Current.Session["mycart"]!=null)
{
arr=(ArrayList)HttpContext.Current.Session["mycart"];
}
else
{
arr=new ArrayList();
HttpContext.Current.Session["mycart"]=arr;
}
arr.Add(item);
return 0;
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand);
this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);
this.button1.Click += new System.EventHandler(this.button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
} private void button1_Click(object sender, System.EventArgs e)
{
Response.Redirect("cart.aspx");
} private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
CShoppingCartItem cart=new CShoppingCartItem(int.Parse(e.Item.Cells[0].Text),e.Item.Cells[1].Text,decimal.Parse(e.Item.Cells[2].Text),int1);
Add(cart);
BindGrid();
}
{
private int intProductID;
private string strProductName;
private decimal decUnitPrice;
private int intQuantity;
public CShoppingCartItem(int intProductID,string strProductName,decimal decUnitPrice,int intQuantity)
{
ProductID = intProductID;
ProductName = strProductName;
UnitPrice = decUnitPrice;
intQuantity = Quantity;
}
public int ProductID
{
get
{
return intProductID;
}
set
{
intProductID=value;
}
} public string ProductName
{
get
{
return strProductName;
}
set
{
strProductName=value;
}
} public decimal UnitPrice
{
get
{
return decUnitPrice;
}
set
{
decUnitPrice=value;
}
} public int Quantity
{
get
{
return intQuantity;
}
set
{
intQuantity=value;
}
} }
{
if(!Page.IsPostBack)
{
FillCartFromSession();
}
// 在此处放置用户代码以初始化页面
} public int Remove(CShoppingCartItem item)
{
ArrayList items=(ArrayList)HttpContext.Current.Session["mycart"];
for(int i=0;i<items.Count;i++)
{
if(((CShoppingCartItem)items[i]).ProductID==item.ProductID)
{
items.RemoveAt(i);
break;
}
}
return 0;
}
public System.Collections.ArrayList GetItems()
{
return (ArrayList)HttpContext.Current.Session["mycart"];
} private void FillCartFromSession()
{
CShoppingCartItem AllItem = null;
ArrayList AllList = GetItems();
DataGrid1.DataSource=AllList;
DataGrid1.DataBind();
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand);
this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
Response.Redirect("WebForm1.aspx");
} private void Button2_Click(object sender, System.EventArgs e)
{
//now you can iterate through cookies collection
//and DataGrid and get details of all items
//then add your code here to insert into database
} private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
CShoppingCartItem cart=new CShoppingCartItem(int.Parse(e.Item.Cells[0].Text),e.Item.Cells[1].Text,decimal.Parse(e.Item.Cells[2].Text),int.Parse(e.Item.Cells[3].Text));
Remove(cart);
FillCartFromSession();
这是存到SESSION的,我也是新手,借鉴别人的