|
管理提醒: 本帖被 醉雪枫叶 执行锁定操作(2007-04-29)描述:1
图片:
vs2005做产品维护页面,连的SQL2K数据库,用datagrid显示的数据编辑数据
007没有输入完整的信息,为什么就删出不掉呢
那页代码
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="productservice.aspx.vb" Inherits="productservice" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>产品维护</title>
</head>
<body background="bg.gif">
<form id="form1" runat="server" method="post">
<div>
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%">
<tr>
<td style="width: 200px">
<asp:Menu ID="Menu1" runat="server" BackColor="#F7F6F3" DynamicHorizontalOffset="2"
Font-Names="Verdana" Font-Size="0.8em" ForeColor="#7C6F57" Height="56px" StaticSubMenuIndent="10px"
Width="96px">
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
<DynamicMenuStyle BackColor="#F7F6F3" />
<StaticSelectedStyle BackColor="#5D7B9D" />
<DynamicSelectedStyle BackColor="#5D7B9D" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<Items>
<asp:MenuItem NavigateUrl="~/productservice.aspx" Text="产品维护" Value="产品维护"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/searchproduct.aspx" Text="查询产品" Value="查询产品"></asp:MenuItem>
</Items>
<StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
</asp:Menu>
</td>
<td>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="商品编号" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
<asp:BoundField DataField="商品编号" HeaderText="商品编号" ReadOnly="True" SortExpression="商品编号" />
<asp:BoundField DataField="商品名称" HeaderText="商品名称" SortExpression="商品名称" />
<asp:BoundField DataField="单价" HeaderText="单价" SortExpression="单价" />
<asp:BoundField DataField="厂家" HeaderText="厂家" SortExpression="厂家" />
<asp:BoundField DataField="商品规格" HeaderText="商品规格" SortExpression="商品规格" />
<asp:BoundField DataField="上架日期" HeaderText="上架日期" SortExpression="上架日期" />
</Columns>
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:bbsuser1ConnectionString %>" DeleteCommand="DELETE FROM [product] WHERE [商品编号] = @original_商品编号 AND [商品名称] = @original_商品名称 AND [单价] = @original_单价 AND [厂家] = @original_厂家 AND [商品规格] = @original_商品规格 AND [上架日期] = @original_上架日期"
InsertCommand="INSERT INTO [product] ([商品编号], [商品名称], [单价], [厂家], [商品规格], [上架日期]) VALUES (@商品编号, @商品名称, @单价, @厂家, @商品规格, @上架日期)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [product]"
UpdateCommand="UPDATE [product] SET [商品名称] = @商品名称, [单价] = @单价, [厂家] = @厂家, [商品规格] = @商品规格, [上架日期] = @上架日期 WHERE [商品编号] = @original_商品编号 AND [商品名称] = @original_商品名称 AND [单价] = @original_单价 AND [厂家] = @original_厂家 AND [商品规格] = @original_商品规格 AND [上架日期] = @original_上架日期">
<DeleteParameters>
<asp:Parameter Name="original_商品编号" Type="String" />
<asp:Parameter Name="original_商品名称" Type="String" />
<asp:Parameter Name="original_单价" Type="String" />
<asp:Parameter Name="original_厂家" Type="String" />
<asp:Parameter Name="original_商品规格" Type="String" />
<asp:Parameter Name="original_上架日期" Type="DateTime" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="商品名称" Type="String" />
<asp:Parameter Name="单价" Type="String" />
<asp:Parameter Name="厂家" Type="String" />
<asp:Parameter Name="商品规格" Type="String" />
<asp:Parameter Name="上架日期" Type="DateTime" />
<asp:Parameter Name="original_商品编号" Type="String" />
<asp:Parameter Name="original_商品名称" Type="String" />
<asp:Parameter Name="original_单价" Type="String" />
<asp:Parameter Name="original_厂家" Type="String" />
<asp:Parameter Name="original_商品规格" Type="String" />
<asp:Parameter Name="original_上架日期" Type="DateTime" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="商品编号" Type="String" />
<asp:Parameter Name="商品名称" Type="String" />
<asp:Parameter Name="单价" Type="String" />
<asp:Parameter Name="厂家" Type="String" />
<asp:Parameter Name="商品规格" Type="String" />
<asp:Parameter Name="上架日期" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>
<asp:FormView ID="FormView1" runat="server" AllowPaging="True" CellPadding="4" DataKeyNames="商品编号"
DataSourceID="SqlDataSource1" ForeColor="#333333" Width="544px">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<EditItemTemplate>
商品编号:
<asp:Label ID="商品编号Label1" runat="server" Text='<%# Eval("商品编号") %>'></asp:Label><br />
商品名称:
<asp:TextBox ID="商品名称TextBox" runat="server" Text='<%# Bind("商品名称") %>'>
</asp:TextBox><br />
单价:
<asp:TextBox ID="单价TextBox" runat="server" Text='<%# Bind("单价") %>'>
</asp:TextBox><br />
厂家:
<asp:TextBox ID="厂家TextBox" runat="server" Text='<%# Bind("厂家") %>'>
</asp:TextBox><br />
商品规格:
<asp:TextBox ID="商品规格TextBox" runat="server" Text='<%# Bind("商品规格") %>'>
</asp:TextBox><br />
上架日期:
<asp:TextBox ID="上架日期TextBox" runat="server" Text='<%# Bind("上架日期") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="更新">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消">
</asp:LinkButton>
</EditItemTemplate>
<RowStyle BackColor="#EFF3FB" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<InsertItemTemplate>
商品编号:
<asp:TextBox ID="商品编号TextBox" runat="server" Text='<%# Bind("商品编号") %>'>
</asp:TextBox><br />
商品名称:
<asp:TextBox ID="商品名称TextBox" runat="server" Text='<%# Bind("商品名称") %>'>
</asp:TextBox><br />
单价:
<asp:TextBox ID="单价TextBox" runat="server" Text='<%# Bind("单价") %>'>
</asp:TextBox><br />
厂家:
<asp:TextBox ID="厂家TextBox" runat="server" Text='<%# Bind("厂家") %>'>
</asp:TextBox><br />
商品规格:
<asp:TextBox ID="商品规格TextBox" runat="server" Text='<%# Bind("商品规格") %>'>
</asp:TextBox><br />
上架日期:
<asp:TextBox ID="上架日期TextBox" runat="server" Text='<%# Bind("上架日期") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="插入">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
商品编号:
<asp:Label ID="商品编号Label" runat="server" Text='<%# Eval("商品编号") %>'></asp:Label><br />
商品名称: <asp:Label ID="商品名称Label" runat="server"
Text='<%# Bind("商品名称") %>'></asp:Label><br />
单价:
<asp:Label ID="单价Label" runat="server" Text='<%# Bind("单价") %>'></asp:Label><br />
厂家: <asp:Label
ID="厂家Label" runat="server" Text='<%# Bind("厂家") %>'></asp:Label><br />
商品规格: <asp:Label ID="商品规格Label" runat="server"
Text='<%# Bind("商品规格") %>'></asp:Label><br />
上架日期:
<asp:Label ID="上架日期Label" runat="server" Text='<%# Bind("上架日期") %>'></asp:Label><br />
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
Text="编辑"></asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False"
CommandName="Delete" Text="删除"></asp:LinkButton>
<asp:LinkButton ID="NewButton" runat="server"
CausesValidation="False" CommandName="New" Text="新建"></asp:LinkButton>
</ItemTemplate>
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:bbsuser1ConnectionString %>" DeleteCommand="DELETE FROM [product] WHERE [商品编号] = @original_商品编号 AND [商品名称] = @original_商品名称 AND [单价] = @original_单价 AND [厂家] = @original_厂家 AND [商品规格] = @original_商品规格 AND [上架日期] = @original_上架日期"
InsertCommand="INSERT INTO [product] ([商品编号], [商品名称], [单价], [厂家], [商品规格], [上架日期]) VALUES (@商品编号, @商品名称, @单价, @厂家, @商品规格, @上架日期)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [product]"
UpdateCommand="UPDATE [product] SET [商品名称] = @商品名称, [单价] = @单价, [厂家] = @厂家, [商品规格] = @商品规格, [上架日期] = @上架日期 WHERE [商品编号] = @original_商品编号 AND [商品名称] = @original_商品名称 AND [单价] = @original_单价 AND [厂家] = @original_厂家 AND [商品规格] = @original_商品规格 AND [上架日期] = @original_上架日期">
<DeleteParameters>
<asp:Parameter Name="original_商品编号" Type="String" />
<asp:Parameter Name="original_商品名称" Type="String" />
<asp:Parameter Name="original_单价" Type="String" />
<asp:Parameter Name="original_厂家" Type="String" />
<asp:Parameter Name="original_商品规格" Type="String" />
<asp:Parameter Name="original_上架日期" Type="DateTime" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="商品名称" Type="String" />
<asp:Parameter Name="单价" Type="String" />
<asp:Parameter Name="厂家" Type="String" />
<asp:Parameter Name="商品规格" Type="String" />
<asp:Parameter Name="上架日期" Type="DateTime" />
<asp:Parameter Name="original_商品编号" Type="String" />
<asp:Parameter Name="original_商品名称" Type="String" />
<asp:Parameter Name="original_单价" Type="String" />
<asp:Parameter Name="original_厂家" Type="String" />
<asp:Parameter Name="original_商品规格" Type="String" />
<asp:Parameter Name="original_上架日期" Type="DateTime" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="商品编号" Type="String" />
<asp:Parameter Name="商品名称" Type="String" />
<asp:Parameter Name="单价" Type="String" />
<asp:Parameter Name="厂家" Type="String" />
<asp:Parameter Name="商品规格" Type="String" />
<asp:Parameter Name="上架日期" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>
</td>
</tr>
</table>
<br />
<div>
</div>
</div>
</form>
</body>
</html>
[ 此贴被醉雪枫叶在2007-04-29 11:41重新编辑 ] |
|