我制作了一个GridView
带有删除和编辑链接的按钮来执行编辑和删除操作。这适用于编辑按钮,但不适用于删除按钮。问题是什么?
当我运行我的应用程序时,它给了我这个错误:
必须声明标量变量“@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>