Hi,
I am trying to build a report programmatically without using the wizard. In this report am using parameter which also should be done programmatically according to my data, and through a query that also be added.
I tried this >> http://www.telerik.com/help/reporting/programmatic-creating-report.html
But I don’t know why am getting and empty report?!
Also the parameters and filter?!
Is there is any procedures behind that
this is a part of what i did, i might be missing something,, lemme know please?
Thanks in advance
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports Telerik.Reporting
Imports Telerik.Reporting.Drawing
Imports System.Data.SqlClient
Partial Public Class Visitreport
Inherits Telerik.Reporting.Report
Public Sub New()
InitializeComponent()
Dim report As New Report()
'Dim sql As String = "SELECT "
Dim sql As String = ""
Dim connectionString As String = ""
Dim adapter As New SqlDataAdapter(sql, connectionString)
report.DataSource = adapter
'creating item programatically
Dim detail As New DetailSection()
Me.detail.Height = New Telerik.Reporting.Drawing.Unit(3, Telerik.Reporting.Drawing.UnitType.Inch)
Me.detail.Name = "detail"
report.Items.Add(DirectCast(detail, ReportItemBase))
Dim panel1 As New Telerik.Reporting.Panel()
Dim textBox1 As New Telerik.Reporting.TextBox()
'panel1
panel1.Location = New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(1, Telerik.Reporting.Drawing.UnitType.Cm), New Telerik.Reporting.Drawing.Unit(1, Telerik.Reporting.Drawing.UnitType.Cm))
panel1.Size = New Telerik.Reporting.Drawing.SizeU(New Telerik.Reporting.Drawing.Unit(8.5, Telerik.Reporting.Drawing.UnitType.Cm), New Telerik.Reporting.Drawing.Unit(3.5, Telerik.Reporting.Drawing.UnitType.Cm))
panel1.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid
'textBox1
textBox1.Location = New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Cm), New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Cm))
textBox1.Name = "NameDataTextBox"
textBox1.Size = New Telerik.Reporting.Drawing.SizeU(New Telerik.Reporting.Drawing.Unit(5, Telerik.Reporting.Drawing.UnitType.Cm), New Telerik.Reporting.Drawing.Unit(0.6, Telerik.Reporting.Drawing.UnitType.Cm))
textBox1.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid
textBox1.StyleName = "Data"
textBox1.Value = "=Fields.AssignTo"
panel1.Items.AddRange(New Telerik.Reporting.ReportItemBase() {textBox1})
detail.Items.AddRange(New Telerik.Reporting.ReportItemBase() {panel1})
Dim reportParameter1 As New Telerik.Reporting.ReportParameter()
reportParameter1.Name = "Parameter1"
reportParameter1.Text = "Enter Value for Parameter1"
reportParameter1.Type = Telerik.Reporting.ReportParameterType.Integer
reportParameter1.AllowBlank = False
reportParameter1.AllowNull = False
reportParameter1.Value = "=10"
reportParameter1.Visible = True
report.ReportParameters.Add(reportParameter1)
reportParameter1.AvailableValues.DataSource = adapter
reportParameter1.AvailableValues.ValueMember = "= Fields.AssignTo"
reportParameter1.AvailableValues.DisplayMember = "= Fields.AssignTo"
Dim filter1 As New Telerik.Reporting.Data.Filter()
filter1.Expression = "=Fields.AssignTo"
filter1.Operator = Telerik.Reporting.Data.FilterOperator.Equal
filter1.Value = "=Parameters.AssignTo"
reportParameter1.AvailableValues.Filters.AddRange(New Telerik.Reporting.Data.Filter() {filter1})
Dim sorting1 As New Telerik.Reporting.Data.Sorting()
sorting1.Expression = "=Fields.AssignTo"
sorting1.Direction = Telerik.Reporting.Data.SortDirection.Asc
reportParameter1.AvailableValues.Sortings.AddRange(New Telerik.Reporting.Data.Sorting() {sorting1})
' report.ReportParameters("AssignTo").Value = ""
End Sub
Private Sub detail_ItemDataBound(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles detail.ItemDataBound
'Take the Telerik.Reporting.Processing.Report instance
'Dim report As Telerik.Reporting.Processing.Report = DirectCast(sender, Telerik.Reporting.Processing.Report)
' Transfer the value of the processing instance of ReportParameter
' to the parameter value of the sqlDataSource component
' Me.SqlDataSource1.Parameters(0).Value = report.Parameters("AssignTo").Value
' Set the SqlDataSource component as it's DataSource
report.DataSource = Me.SqlDataSource1
End Sub
End Class