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

Table control databinding

5 Answers 310 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 27 Apr 2009, 09:09 PM
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.

5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 30 Apr 2009, 01:41 PM
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);

private
 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(); 
         adapter.Fill(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,
Steve
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.
0
raju
Top achievements
Rank 2
answered on 02 May 2009, 03:02 AM
Hi,,
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)
        InitializeComponent()
        ShowInfo(InvoiceID)
    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
        Try
            Dim da As New MySqlDataAdapter
            Dim bind As New BindingSource
            Dim strConn As String = ConfigurationManager.AppSettings("ConnectionString")
            Dim objConn As MySqlConnection = New MySqlConnection(strConn)
            objConn.Open()
            da = New MySqlDataAdapter(strQuery, objConn)
            da.FillSchema(ds, SchemaType.Source, strTbl)
            da.Fill(ds, strTbl)
            objConn.Close()
            Return ds
        Catch ex As Exception
            Return ds
        End Try
    End Function
End Class


Regards
Raju
0
moftol
Top achievements
Rank 1
answered on 20 Jan 2013, 01:56 PM
Hi

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.

thanks.
0
moftol
Top achievements
Rank 1
answered on 20 Jan 2013, 01:59 PM
the report is having table item.
0
Stef
Telerik team
answered on 24 Jan 2013, 10:08 AM
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,
Stef
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!

Tags
General Discussions
Asked by
Mark
Top achievements
Rank 1
Answers by
Steve
Telerik team
raju
Top achievements
Rank 2
moftol
Top achievements
Rank 1
Stef
Telerik team
Share this question
or