title: Delete users from membership
body: <p>I made a <code>GridView</code> with delete and edit link buttons to perform edit and delete action. This works for the edit button, but not for the delete button. What is the problem?</p>
  
  <p>And when I run my application, it gives me this error:</p>
  
  <blockquote>
    <p>Must declare the scalar variable "@UserName"</p>
  </blockquote>
  
  <pre><code>&lt;asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt;
  &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
  DataSourceID="SqlDataSource1"&gt;
  &lt;Columns&gt;
  &lt;asp:CheckBoxField DataField="IsApproved" HeaderText="IsApproved"
  SortExpression="IsApproved" /&gt;
  &lt;asp:BoundField DataField="UserName" HeaderText="UserName" 
  SortExpression="UserName" /&gt;
  &lt;asp:CheckBoxField DataField="IsLockedOut" HeaderText="IsLockedOut" 
  SortExpression="IsLockedOut" /&gt;
  &lt;asp:CommandField ShowEditButton="True" ShowDeleteButton="True" /&gt;
  &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" 
  ConnectionString="&lt;%$ ConnectionStrings:ApplicationServices %&gt;" 
  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)"&gt;
  &lt;UpdateParameters&gt;
  &lt;asp:Parameter Name="IsApproved" /&gt;
  &lt;asp:Parameter Name="IsLockedOut" /&gt;
  &lt;asp:Parameter Name="UserName" /&gt;
  &lt;/UpdateParameters&gt; 
  &lt;DeleteParameters&gt;
  &lt;asp:Parameter Name="IsApproved" /&gt;
  &lt;asp:Parameter Name="IsLockedOut" /&gt;
  &lt;asp:Parameter Name="UserName" /&gt;
  &lt;/DeleteParameters&gt; 
  
  &lt;/asp:SqlDataSource&gt;
  &lt;/asp:Content&gt;
  </code></pre>