DataBinding Methodology

2 posts, 0 answers
  1. hchattaway
    hchattaway avatar
    67 posts
    Member since:
    Feb 2007

    Posted 27 Jun 2007 Link to this post


    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> 
                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

  2. Svetoslav
    Svetoslav avatar
    649 posts

    Posted 28 Jun 2007 Link to this post

    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,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top