aspnetmvc-120100-components-query-builder-getting-started-lesson-2-use-the-resulting-query.md
This lesson demonstrates how to use queries that the Query Builder generates to supply data to the DevExpress ASP.NET MVC GridView control.
Create a new Partial View file (for instance, GridViewPartial.cshtml ), since the GridView updating mechanism requires declaring its extension in the Partial View. Use the ExtensionsFactory.GridView helper method and pass the GridViewSettings object as a parameter to configure the extension as shown below:
Move the Query Builder extension’s declaration from the Index.cshtml file to a new separate View file ( QueryBuilder.cshtml in this example).
In the Index.cshtml file, render the GridView and provide the capability to run the Query Builder using the following code:
In the Query Builder controller, modify the Save action to save the QueryBuilderSaveCallbackResult.SelectStatement property value to the session variable and redirect a browser to the page with the GridView.
Open the HomeController file and implement the action methods as demonstrated below:
Run the application to see the GridView displaying the default data and click the Run Query Builder link.
In the invoked Query Builder, construct a query and click the Save toolbar button.
This opens the page with the GridView that shows the obtained data.