This is a migrated thread and some comments may be shown as answers.

DataBinding Methodology

1 Answer 121 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
hchattaway
Top achievements
Rank 1
hchattaway asked on 28 Jun 2007, 01:55 AM
Hello

I am experimenting with different databinding methods and wanted to get something confirmed...

This technique...

 
public partial class Report1 : Report 
    { 
        SqlCommand sqlSelectCommand1 = new SqlCommand(); 
        SqlConnection sqlConnection1 = new SqlConnection(); 
        SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter(); 
 
        public Report1() 
        { 
            /// <summary> 
            /// Required for telerik Reporting designer support 
            /// </summary> 
            InitializeComponent(); 
 
            sqlConnection1.ConnectionString = "server=(local);database=TroubleTicket;Trusted_Connection=true"
            sqlSelectCommand1.CommandText = "SELECT * FROM app_projects"
            sqlSelectCommand1.Connection = sqlConnection1; 
            sqlDataAdapter1.SelectCommand = sqlSelectCommand1; 
            this.DataSource = sqlDataAdapter1; 
 
        } 
    } 

of putting the databinding logic after the call to "InitializeComponent", works during report development but does NOT allow for drag and drop from the data explorer, correct?

Then the technique of setting the datasource of the report by setting the report properties at runtime, does not allow for the previewing of data during report development. Correct?

Pros and cons of each?

Thanks for your help!
Harold Chattaway

1 Answer, 1 is accepted

Sort by
0
Svetoslav
Telerik team
answered on 28 Jun 2007, 10:54 AM
Hi hchattaway,

Both of your statements are absolutely correct. There is a 3rd approach that satisfies both - design and run time. Add the DataSource initialization in the Report's IntializeComponent method. You can do this by hand but the preferred way is to use the DataSource's editor (from the VisualStudio's PropertyGrid) and the Data Source Wizard.

If you choose to code this by yourself, have in mind that VisualStudio has strong requirements to what the InitializeComponent should contain. For example, you can examine the SimpleReport example from the Telerik Reporting samples (in C# or VB.NET).
 

All the best,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
hchattaway
Top achievements
Rank 1
Answers by
Svetoslav
Telerik team
Share this question
or