0
我有一個DataGridView啓用刪除,但它從來沒有發生。整個網格消失(多行),但我點擊行的刪除從不發生。從DataGridView SQL刪除沒有發生
我可以在sql管理工作室中手動運行sql語句,它工作得很好,但似乎從未從網頁運行。
我不知道從哪裏去,我從來沒有像這樣從GridView的問題。
的SqlDataSource:
<asp:SqlDataSource ID="SqlDataSourceVisitors" runat="server" ConnectionString="constring" DeleteCommand="DELETE FROM [RegisteredVisitors] WHERE [PK] = @PK UPDATE [dbo].[Users] SET [NumberOfVisitors] = (SELECT [NumberOfVisitors] FROM [dbo].[NumberOfVisitors] WHERE [ResidentName] = @ResidentName) -1 WHERE [ResidentName] = @ResidentName" InsertCommand="INSERT INTO [RegisteredVisitors] ([ResidentName], [ResidentAddress], [VisitorCode], [VisitorName]) VALUES (@ResidentName, @ResidentAddress, @VisitorCode, @VisitorName)" SelectCommand="SELECT * FROM [RegisteredVisitors] WHERE ([ResidentName] = @ResidentName)" UpdateCommand="UPDATE [RegisteredVisitors] SET [ResidentName] = @ResidentName, [ResidentAddress] = @ResidentAddress, [VisitorCode] = @VisitorCode, [VisitorName] = @VisitorName WHERE [PK] = @PK" ProviderName="System.Data.SqlClient">
<DeleteParameters>
<asp:Parameter Name="PK" Type="Int32" />
<asp:Parameter Name="ResidentName" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="ResidentName" Type="String" />
<asp:Parameter Name="ResidentAddress" Type="String" />
<asp:Parameter Name="VisitorCode" Type="Int32" />
<asp:Parameter Name="VisitorName" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="txtboxSelectedResident" Name="ResidentName" PropertyName="Text" Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="ResidentName" Type="String" />
<asp:Parameter Name="ResidentAddress" Type="String" />
<asp:Parameter Name="VisitorCode" Type="Int32" />
<asp:Parameter Name="VisitorName" Type="String" />
<asp:Parameter Name="PK" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
GridView控件:
<asp:GridView ID="DataGridViewVisitors" runat="server" CellPadding="4" DataSourceID="SqlDataSourceVisitors" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
分離不是答案,完全沒有第二條陳述。 – Crowcoder
我需要其他聲明。 – birddseedd
@birddseedd你用分號嘗試過嗎? –