Delete Command on GridView

I have an SqlDatasource that I am using with a GridView.  Everything works fine except for the delete command on the SqlDatasource.  I have two parameters on the DELETE command that I simply want it to delete from the table where those two parameters equal what the user selected to delete on the Gridview.  Here is the code for the SqlDataSource:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:MyConnectionString2 %>"
        DeleteCommand="DELETE FROM table1 WHERE column1 = @param1 AND column2 = @param2"
        <asp:Parameter Name="param1" />
        <asp:Parameter Name="param2" />

It gives me an error telling me I need to declare the scalar variable "param2" and I cannot figure out why.  I have it declared right there in the code
Who is Participating?
did you set your DataKeyNames property on the gridview control to the column in question?
also take a look at this link
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.