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