I need to show the data in GridControl/DataGridView at run-time. So for that I've used the devexpress DashboardDesigner control on form and set its visibility to false. And on button click I called the DashoardDesigner.ShowDataSourceWizard() to run the data connection wizard. After the wizard completion I need to show the output of the query on my GridControl/DataGridView. For that I write
private void button1_Click(object sender, EventArgs e)
{
dashboardDesigner1.ShowDataSourceWizard();
SqlDataSource objSqlDataSource = (DevExpress.DataAccess.Sql.SqlDataSource)dashboardDesigner1.SelectedDataSource;
dataGridView1.DataSource = objSqlDataSource;
dataGridView1.DataMember = objSqlDataSource.Queries[0].Name;
objSqlDataSource.Fill();
dataGridView1.Refresh();
}
The code is build successfully but the output is not shown in grid.
The DashboardSqlDataSource component created by the Dashboard Designer control can be used only in dashboards and cannot be used in other controls.
To introduce the required functionality without dashboards, use the SqlDataSource component and the SqlDataSourceUIHelper class. SqlDataSourceUIHelper provides an API to invoke various tools available to end users for configuring the data connection settings in an application.
SqlDataSource objSqlDataSource = new SqlDataSource();
if(SqlDataSourceUIHelper.ConfigureConnection(objSqlDataSource))
{
if(SqlDataSourceUIHelper.ManageQueries(objSqlDataSource))
{
dataGridView1.DataSource = objSqlDataSource;
dataGridView1.DataMember = objSqlDataSource.Queries[0].Name;
objSqlDataSource.Fill();
dataGridView1.Refresh();
}
}