Table control databinding

6 posts, 0 answers
  1. Mark
    Mark avatar
    41 posts
    Member since:
    Nov 2008

    Posted 27 Apr 2009 Link to this post

    I have a report that contains a number of fields, and a table control. My data source is a list of "user" data objects, each of which in turn contains a list of "phone number" objects.

    I create the report programmatically, and then assign my user list to its DataSource property. So far so good. Now what is the correct way to get each user's phone number list into the table? Should this be done within the detail section itemdatabound event handler? This is the approach I tried initially, and I'm having some problems with it, so I wanted to confirm best practices before proceeding further.
  2. Steve
    Steve avatar
    10941 posts

    Posted 30 Apr 2009 Link to this post

    Hi Mark,

    The DataSource of the report is a separate thing from the DataSource of the table item itself, which can be considered as separate "data" region. If you want to bind it programmatically, you should use its NeedDataSource event i.e.:

    table1.NeedDataSource += new EventHandler(table1_NeedDataSource);

     void table1_NeedDataSource(object sender, EventArgs e) 
                 string sql = @"SELECT Name, ProductNumber FROM Production.Product"
             string connectionString = 
               "Data Source=(local)\\SQLEXPRESS2005;Initial Catalog=AdventureWorks;Integrated Security=True"
             SqlDataAdapter adapter = new SqlDataAdapter(sql, connectionString); 
             DataSet dataSet = new DataSet(); 
                Telerik.Reporting.Processing.Table procTable = (Telerik.Reporting.Processing.Table)sender; 
                procTable.DataSource = dataSet; 

    If you're providing the data directly to the definition table item, then you can setup one table at design time and see the generated code for it in the InitializeComponent() method for sample code snippet.

    Sincerely yours,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. raju
    raju avatar
    15 posts
    Member since:
    Feb 2009

    Posted 01 May 2009 Link to this post

    I can not able to add datarows in to the table, I am assign dataset programatically,
    Below is mycode extract, Please give me advice.

    Partial Public Class DAReport
        Inherits Telerik.Reporting.Report
        Public Sub New(ByVal InvoiceID as integer)
        End Sub

    Sub ShowInfo(ByVal InvoiceID as integer)
     Dim oView As System.Data.DataView = Nothing
     Dim strQuery As String = "select * from invoice_lineItems where invid="& InvoiceID
     Table1.DataSource = getDataSet(strQuery, "invoice_lineItems")
     Table1.DataMember = "da_invoice_lineitems"
    End Sub


    Public Function getDataSet(ByVal strQuery As String, ByVal strTbl As String) As System.Data.DataSet

            Dim ds As System.Data.DataSet = New DataSet
                Dim da As New MySqlDataAdapter
                Dim bind As New BindingSource
                Dim strConn As String = ConfigurationManager.AppSettings("ConnectionString")
                Dim objConn As MySqlConnection = New MySqlConnection(strConn)
                da = New MySqlDataAdapter(strQuery, objConn)
                da.FillSchema(ds, SchemaType.Source, strTbl)
                da.Fill(ds, strTbl)
                Return ds
            Catch ex As Exception
                Return ds
            End Try
        End Function
    End Class

  4. moftol
    moftol avatar
    17 posts
    Member since:
    Feb 2008

    Posted 20 Jan 2013 Link to this post


    i am binding the report to a data table but it is only showing one record, before it was showing all the records and i created an application in which the table item is showing all the data, but i do not what is the problem here, please if any body give me some clue.
    the data table is returning all the data.

  5. moftol
    moftol avatar
    17 posts
    Member since:
    Feb 2008

    Posted 20 Jan 2013 Link to this post

    the report is having table item.
  6. Stef
    Stef avatar
    3611 posts

    Posted 24 Jan 2013 Link to this post

    Hi farooq,

    I am not sure I understand your scenario. Do you use any data source components or the DataTable objects is passed directly to the report? Have you set any filter expressions? I have attached two sample reports illustrating NeedDataSource to pass data and objectDatasource component.

    If you need help on this, elaborate on your report structure, data, databinding and settings.

    All the best,
    the Telerik team

    HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Back to Top