Hi, I have a gridview which takes it's values from an sqldatassource.I have an extra column in gridview which contains a linkbutton for each row( delete button) and when the user clicks on the button a pop up fires for delete confirmation, i click ok and i see this error message "Must declare the scalar variable "@id_polis". and "Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Must declare the scalar variable "@id_polis".Source Error:
Line 52: connection.Open(); Line 53: SqlCommand Command = new SqlCommand("DELETE FROM ?????S WHERE [id_polis] = @id_polis ", connection); Line 54: Command.ExecuteNonQuery(); Line 55: Command.Connection.Close(); Line 56: GridView1.DataBind();
.Here is what i have done so far :(button code) :
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete" Text="DELETE" OnClientClick='<%# Eval("id_polis","return confirm(\"Delete the datasource {0}?\");") %>'></asp:LinkButton>
{
connection.Open();
Command.ExecuteNonQuery();
Command.Connection.Close();
GridView1.DataBind();
}