我做了一個GridView
刪除和編輯鏈接按鈕來執行編輯和刪除操作。這適用於編輯按鈕,但不適用於刪除按鈕。問題是什麼?刪除用戶從會員
當我跑我的應用程序,它給了我這個錯誤:
Must declare the scalar variable "@UserName"
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:CheckBoxField DataField="IsApproved" HeaderText="IsApproved"
SortExpression="IsApproved" />
<asp:BoundField DataField="UserName" HeaderText="UserName"
SortExpression="UserName" />
<asp:CheckBoxField DataField="IsLockedOut" HeaderText="IsLockedOut"
SortExpression="IsLockedOut" />
<asp:CommandField ShowEditButton="True" ShowDeleteButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
SelectCommand="SELECT [IsApproved], [UserName], [IsLockedOut] FROM [vw_aspnet_MembershipUsers]"
UpdateCommand="UPDATE [vw_aspnet_MembershipUsers] SET IsApproved = @IsApproved, IsLockedOut = @IsLockedOut WHERE (UserName = @UserName)"
DeleteCommand="DELETE FROM [vw_aspnet_MembershipUsers] WHERE (UserName = @UserName)">
<UpdateParameters>
<asp:Parameter Name="IsApproved" />
<asp:Parameter Name="IsLockedOut" />
<asp:Parameter Name="UserName" />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="IsApproved" />
<asp:Parameter Name="IsLockedOut" />
<asp:Parameter Name="UserName" />
</DeleteParameters>
</asp:SqlDataSource>
</asp:Content>
你應該或者通過會員'Membership.DeleteUser(user.UserName)'或通過存儲過程'[DBO]刪除刪除。 [aspnet_Users_DeleteUser]' –