Hi. I'm using Visual Studio 2005 with VB.
I have a gridview using a SQLDataSource that allows users to edit and delete records. That all works fine. Now I am adding search functionality so that users can search on first and last names and date of birth using input controls that sit above the gridview. That works fine too and the gridview displays the appropriate records matching the search criteria. I modify the SelectCommand of the SQLDataSource when the "Find" button is clicked in order to retrieve matching records.
The problems start when I try to edit a record that has been returned by the search functionality. When I click edit for a record, the gridview refreshes and displays ALL records and the row in edit mode is not the one that I selected. Obviously the row ID is being used to decide which row should be in edit mode but because the result set has changed it's the wrong row.
I've tried using the Page_Load event to check if the search fields are populated, and if so, modify the SelectCommand of the SQLDataSource appropriately, but this has no effect.
How do I resolve this? If my search has returned only one record then if I edit that record it should go into edit mode and still be the only record in the gridview.
All help very much appreciated.