使用DataList实现 加入购物车,编辑,删除,更新,取消功能。要求连一个产品表。
<body>
<form id="form1" runat="server">
<div>
<asp:DataList ID="DataList1" runat="server"
onitemcommand="DataList1_ItemCommand"
oncancelcommand="DataList1_CancelCommand"
ondeletecommand="DataList1_DeleteCommand" oneditcommand="DataList1_EditCommand"
onupdatecommand="DataList1_UpdateCommand">
<EditItemTemplate> www.zzzyk.com
<table style="width: 100%; height: 180px;">
<tr>
<td class="style4">
商品名:</td>
<td class="style2">
<asp:TextBox ID="txtProductName" runat="server"
Text='<%# Eval("ProductName") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="style4">
规格:</td>
<td class="style2">
<asp:TextBox ID="txtProductStandard" runat="server"
Text='<%# Eval("ProductStandard") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="style4">
包装率:</td>
<td class="style2">
<asp:TextBox ID="txtPackagingRatio" runat="server"
Text='<%# Eval("PackagingRatio") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="style4">
商品条码:</td>
<td class="style2">
<asp:TextBox ID="txtArticleNum" runat="server" Text='<%# Eval("ArticleNum") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="style4">
价格:</td>
<td class="style2">
<asp:TextBox ID="txtPrice" runat="server" Text='<%# Eval("Price") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="style4">
<asp:Button ID="btnUpdate" runat="server" CommandArgument='<%# Eval("PId") %>'
CommandName="update" Height="21px" Text="更新" />
</td>
<td class="style2">
<asp:Button ID="btnCancel" runat="server" CommandName="cancel" Text="取消" />
</td>
</tr>
</table>
</EditItemTemplate>
<ItemTemplate>
产品名:<asp:Label ID="lblProductName" runat="server"
Text='<%# Eval("ProductName") %>'></asp:Label>