I have a Gridview on an ASP.net page. I added the delete command to the SQL data source and told the gridview to “Enable Deleting.”
When the delete button is clicked I get an error – “Must declare the scalar variable @oid”.
OID in my case is the primary key of the table I’m wanting to be able to delete from.
The fix is very easy. You want to go to the source view of the page where the gridview is at.
Add: DataKeyNames=”oid” to the asp:gridview code. You need to change oid to the column name you are using to identify the record to delete.
Now you should be able to delete to your heart’s content.