Back to Devexpress

Obtaining and Saving the Resulting Query

aspnet-115030-components-query-builder-obtaining-and-saving-the-resulting-query.md

latest1.7 KB
Original Source

Obtaining and Saving the Resulting Query

  • Dec 17, 2020

When an end-user clicks the Save command on the Query Builder control’s toolbar or the client-side Save method is called, the server-side ASPxQueryBuilder.SaveQuery event occurs. A handler receives an event argument providing access to a string containing the resulting query both as a string value and an internal representation speciffic for the DevExpress Data Access library (a SelectQuery object).

csharp
using DevExpress.DataAccess.Sql;
// ..
protected void ASPxQueryBuilder1_SaveQuery(object sender, DevExpress.XtraReports.Web.SaveQueryEventArgs e) {
    SelectQuery query = e.ResultQuery;
    string queryString = e.SelectStatement;
}
vb
Imports DevExpress.DataAccess.Sql
' ..
Protected Sub ASPxQueryBuilder1_SaveQuery(ByVal sender As Object, ByVal e As DevExpress.XtraReports.Web.SaveQueryEventArgs)
    Dim query As SelectQuery = e.ResultQuery
    Dim queryString As String = e.SelectStatement
End Sub

Note that a SelectQuery can be reopened in the Query Builder for further editing.

csharp
protected void Page_Load(object sender, EventArgs e) {
    ASPxQueryBuilder1.OpenConnection("NorthwindXpo", query);            
}
vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    ASPxQueryBuilder1.OpenConnection("NorthwindXpo", query)
End Sub