Lesson 1 - Add a Query Builder to a Web Application
- 2 minutes to read
This lesson will teach you how to add a Query Builder to an ASP.NET Web Forms application.
To get started with this tutorial, create a new ASP.NET Web Forms application containing one Web Form. To add a Query Builder to the created web application, do the following.
- Select the default Web Form in the Solution Explorer and click the Design button to open the visual designer for this Web Form.
Expand the DX.22.2: Data and Analytics Toolbox group and drop the ASPxQueryBuilder control onto the page.
Next, provide the Query Builder with a data connection required to automatically obtain database schema information and properly generate data provider-specific SQL. To achieve this, add an XPO connection string for your database to the application’s Web.config file.
<connectionStrings> <add name="NorthwindXpo" connectionString= "data source=localhost;integrated security=SSPI;initial catalog=nwind.mdf;XpoProvider=MSSqlServer;"/> </connectionStrings>
Pass the name of the added connection string to the Query Builder’s ASPxQueryBuilder.OpenConnection method on the Page_Load event as shown in the code sample below.
In the application’s Web.config file, add the “resources” section as shown below.
<devExpress> <!-- ... --> <resources> <add type="ThirdParty" /> <add type="DevExtreme" /> </resources> </devExpress>
Alternatively, to avoid automatic loading of any libraries by a control (e.g., when such libraries are already referenced on the web page), declare an empty “resources” section and manually attach DevExtreme resources and the required third-party libraries (such as jQuery and Globalize) to the web page.
Deleting the DevExpress “resources” section from the Web.config file will enable the default behavior (with automatic loading only of DevExtreme, without adding third-party libraries).
To learn more about this configuration, see External Client Libraries.
Run your web application to view the result. Use drag-and-drop to add a data table from the tables list to the current query.
Enable check boxes for data rows that you want to include into the query.
Click the Preview Results () toolbar command to preview the results of the query execution.