Gridview Capture SQL Select Command Being Executed
Is ther开发者_运维技巧e anyway to capture the command the Gridview is executing for later use? I have gridview that uses parameters from a few textboxes, so its generating a custom statement. I am wondering is there anyway for me to get that statement either during or after it is executing it, and then returning the results. I need to save it, so that I can populate a CSV file with the data that was returned?
Gridview doesn't execute commands. Are you hooking it up to a SqlDataSource by chance? Whatever you're attaching it to, you want to look at the datasource itself as opposed to the gridview when looking for a select event to hook in to.
There are a couple ways you could "export" to csv from a GridView and/or a specific datasource if you want to. Can you tell us a bit more about your requirements?
@mfredrickson has a good suggestion too. If you're not getting the answer you want by watching the application, you can always get a definitive answer from the database itself...
Not that isn't directly possible because from your explanation I understand you are using some DataSource control and probably a parameterized query.
But executing the same query in code isn't too difficult. Check this article on executing Parametrized query in C# You pass the values from your textbox for the parameters in your query.
That's pretty much done behind the scene by SqlDataSource as well which gather values from your provided input text controls.
精彩评论