I have a GridView which I am populating by calling a method to return a datatable with two columns. After I return the datatable, I bind it to the gridview and display it.
I am not using a SqlDataSource or an ObjectDataSource, so what is the proper way to Delete a row from the gridview and the underlying data in the database. I just need to delete from one table which is called portfolio. It has 3 columns, ID, which is the unique key, PortfolioID, and PortfolioName. The datatable returns the PortfolioName and the number of items in the Portfolio. I was thinking I could do this in the Row_Deleting event where I would do something like:
DELETE * FROM Portfolio WHERE PortfolioID = @PortfolioID
Am I on the right track and how would I do this? Could I bind the PortfolioID to the GridView DataKey property (What is the correct syntax to do this?)