- Joined
- Oct 22, 2008
- Messages
- 2
- Reaction score
- 0
Hey all, got a problem that's been plaguing me for much longer than is justified...
I have a simple ASP.NET web form with a SqlDataSource, GridView, and four text boxes to alter the search criteria of what is displayed. The user clicks a "Search" button which alters SqlDataSource's SelectCommand property based on the values of the text boxes and then updates the GridView. This works well for searching.
However, I need the records to be easily editable after a search. If the user has narrowed down the search to, say, 4 records and then clicks "Edit", the page refreshes and returns all records in the table--after which the user must scroll through pages of records to find the one they just searched for. I suspect what is happening is that the SqlDataSource is reverting to its hardcoded "SelectQuery" property (which is a simple SELECT with no WITH clause). Correct? How do I get it to work such that clicking "Edit" will show edits in the reduced recordset (instead of editing the entire table)?
Note that I have set an UPDATE statement and can update records; it's just a pain when the search results change for editing one record. Also, someone has suggested to add parameters to execute the search. The problem there is that I need to selectively choose which parameters are actually used programtically (something I have already done in application logic); setting parameters will blindly use all of the text boxes.
If anyone could offer some assistance, I'd really appreciate it. Thanks in advance!
(BTW: The codebehind is in VB.NET if that makes any difference.)
-- Ben
I have a simple ASP.NET web form with a SqlDataSource, GridView, and four text boxes to alter the search criteria of what is displayed. The user clicks a "Search" button which alters SqlDataSource's SelectCommand property based on the values of the text boxes and then updates the GridView. This works well for searching.
However, I need the records to be easily editable after a search. If the user has narrowed down the search to, say, 4 records and then clicks "Edit", the page refreshes and returns all records in the table--after which the user must scroll through pages of records to find the one they just searched for. I suspect what is happening is that the SqlDataSource is reverting to its hardcoded "SelectQuery" property (which is a simple SELECT with no WITH clause). Correct? How do I get it to work such that clicking "Edit" will show edits in the reduced recordset (instead of editing the entire table)?
Note that I have set an UPDATE statement and can update records; it's just a pain when the search results change for editing one record. Also, someone has suggested to add parameters to execute the search. The problem there is that I need to selectively choose which parameters are actually used programtically (something I have already done in application logic); setting parameters will blindly use all of the text boxes.
If anyone could offer some assistance, I'd really appreciate it. Thanks in advance!
(BTW: The codebehind is in VB.NET if that makes any difference.)
-- Ben