Datalist控件使用存储过程来分页实现代码
2024-07-10 12:41:10
供稿:网友
--------------前台:-------------------
代码如下:
<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"
onitemdatabound="DataList1_ItemDataBound">
<EditItemTemplate>
<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="Label1" runat="server" Text='<%# Eval("ProductName") %>'></asp:Label>
<br />
规格:<asp:Label ID="Label2" runat="server" Text='<%# Eval("ProductStandard") %>'></asp:Label>
<br />
包装率:<asp:Label ID="Label3" runat="server" Text='<%# Eval("PackagingRatio") %>'></asp:Label>
<br />
商品条码:<asp:Label ID="Label4" runat="server" Text='<%# Eval("ArticleNum") %>'></asp:Label>
<br />
超市价格:<asp:Label ID="Label5" runat="server" Text='<%# Eval("Price") %>'></asp:Label>
<br />
<asp:Button ID="btnEdit" runat="server" Text="编辑" CommandName="Edit" />
<asp:Button ID="btnDelete" runat="server" Text="删除"