asp.net 购物车实现详细代码
2024-07-10 12:39:26
供稿:网友
 
<%@ Page language="c#" Codebehind="shoppingcart.aspx.cs" AutoEventWireup="false" Inherits="myshop.shoppingcart" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML> <HEAD> 
<title>shoppingcart 
</title> 
<meta http-equiv="Content-Type" content="text/html; 
charset=gb2312"> <LINK href="mycss.css" type="text/css" rel="stylesheet"> 
<meta name="vs_defaultClientScript" content="JavaScript"> 
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> 
<body> <center> 
<form id="Form1" runat="server"> <table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td> 
<asp:DataGrid id="ShoppingCartDlt" runat="server" Width="500" BackColor="white" BorderColor="black" ShowFooter="false" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#cecfd6" AutoGenerateColumns="false" MaintainState="true"> <Columns> 
<asp:TemplateColumn HeaderText="删除"> 
<ItemTemplate> <center> 
<asp:CheckBox id="chkProductID" runat="server" /> </center> 
</ItemTemplate> </asp:TemplateColumn> 
<asp:BoundColumn DataField="ProdID" HeaderText="ID" /> 
<asp:BoundColumn DataField="ProName" HeaderText="商品名称" /> 
<asp:BoundColumn DataField="UnitPrice" HeaderText="单价" /> 
<asp:TemplateColumn HeaderText="数量"> 
<ItemTemplate> 
<asp:TextBox id="CountTb" runat="server" Text='<%#DataBinder.Eval( Container.DataItem,"ProdCount" )%>'> </asp:TextBox> 
</ItemTemplate> </asp:TemplateColumn> 
<asp:BoundColumn DataField="TotalPrice" HeaderText="小计( 元 )" /> </Columns> </asp:DataGrid></td> </tr> </table> <br> <table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td> 
<asp:Button id="update" runat="server" Text="更新我的购物车" CssClass="button2" /></td> <td> 
<asp:Button id="CheckOut" runat="server" Text="结算" CssClass="button5" /> 
<input type="button" name="close2" value="继续购物" onClick="window.close( ); 
return false; 
" class="button2"></td> <td align="right"><br> 
<asp:Label id="label" runat="server" Width="100px" Visible="True" ForeColor="#FF8080" Height="18px"></asp:Label></td> </tr> </table> 
</form> </center> 
</body></HTML>=======================================================================================以上为HTML页面部分========================================================================================== 
using System; 
using System.Collections; 
using System.ComponentModel; 
using System.Web.SessionState; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.HtmlControls; 
using System.Web.UI.WebControls;