Hi,
I'm working on an enquiry screen with a WebGrid, some textboxes and a search button. When I click on the search button, I found that the DataSource do query twice.
The first query happens before search button click event and the second query happens after. I don't know why DataSource need to do query twice. Does anyone know how to stop the first query?
Best,
Adam
Can anybody help?
This is an unexpected behavior. Please give me more information regarding how your are connecting to the datasource. You can post your markup for the grid here if you want. I also recommend you have a look at our samples
http://samples.infragistics.com/2009.2/WebFeatureBrowser/Default.aspx->WebGrid->Database Updating.
In general you want to handle either the UpdateRow or the UpdateRowBatch events.
Magued
Hi Adam,
The UpdateRow and UpdateRowBatch events are used if you are updating the database.I have tested the following scenario. A WebGrid attached to an SqlDataSource and a Button. On the post back the selecting event of the SqlDataSource fired only once. The test was done without any updates to the Grid.
Hi Magued,
Thank you for your reply. But I'm creating an enquiry screen. I don't get the reason why I have to handle the UpdateRow or UpdateRowBatch event.
The is the execution sequence I found using VS2008's debugger
1. User fill-in search criteria and click on search button
2. Request postback to server, here the DataSource query once with its original SQL
3. The btnSearch_Click event fire, then I add search criteria (just append to the original SQL, no other actions)
4. DataSource query again and result are send back to client browser
I don't know if it is a correct way to handle SQL in DataSource, but I'm sure the DataSource will query two time for every postback.