我对ASP.NET GridView有疑问。我把GridView放在我的项目中,然后连接SqlDataSource。我的问题是我无法删除行。 我的GridView设置:
我的代码:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="menu_id" DataSourceID="SqlDataSource2" Width="500px">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="menu_id" HeaderText="menu_id" InsertVisible="False" ReadOnly="True" SortExpression="menu_id" />
<asp:BoundField DataField="altmenu_id" HeaderText="altmenu_id" SortExpression="altmenu_id" />
<asp:BoundField DataField="menu_adi" HeaderText="menu_adi" SortExpression="menu_adi" />
<asp:BoundField DataField="url" HeaderText="url" SortExpression="url" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:thalesbilisimConnectionString2 %>" DeleteCommand="DELETE FROM [menuler] WHERE [menu_id] = @original_menu_id AND [altmenu_id] = @original_altmenu_id AND [menu_adi] = @original_menu_adi AND (([url] = @original_url) OR ([url] IS NULL AND @original_url IS NULL))" InsertCommand="INSERT INTO [menuler] ([altmenu_id], [menu_adi], [url]) VALUES (@altmenu_id, @menu_adi, @url)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [menuler] WHERE ([altmenu_id] = @altmenu_id)" UpdateCommand="UPDATE [menuler] SET [altmenu_id] = @altmenu_id, [menu_adi] = @menu_adi, [url] = @url WHERE [menu_id] = @original_menu_id AND [altmenu_id] = @original_altmenu_id AND [menu_adi] = @original_menu_adi AND (([url] = @original_url) OR ([url] IS NULL AND @original_url IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_menu_id" Type="Int32" />
<asp:Parameter Name="original_altmenu_id" Type="Int32" />
<asp:Parameter Name="original_menu_adi" Type="String" />
<asp:Parameter Name="original_url" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="altmenu_id" Type="Int32" />
<asp:Parameter Name="menu_adi" Type="String" />
<asp:Parameter Name="url" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:Parameter DefaultValue="0" Name="altmenu_id" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="altmenu_id" Type="Int32" />
<asp:Parameter Name="menu_adi" Type="String" />
<asp:Parameter Name="url" Type="String" />
<asp:Parameter Name="original_menu_id" Type="Int32" />
<asp:Parameter Name="original_altmenu_id" Type="Int32" />
<asp:Parameter Name="original_menu_adi" Type="String" />
<asp:Parameter Name="original_url" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>