GridView Edit With Dynamic SelectCommand?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top