I Have this:
Me.sqlSelectCommand1.Parameters.AddRange(New System.Data.SqlClient.SqlParameter() {New System.Data.SqlClient.SqlParameter("@user_id", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "user_id", System.Data.DataRowVersion.Current, "aaa")}) |
But I want to put the value of the label where the "aaa" is. Inside my report.vb I don't have access to the label...
Any help please?
Thanks!
12 Answers, 1 is accepted
It is normal that you cannot access the label from inside the Report directly because this behavior is by design. But there are several of approaches you can use. For example you can pass the label's to the report through its constructor
Public Class Report1
Inherits Report
Public Sub New(ByVal userID As String)
'
' Required for Telerik Reporting designer support
'
InitializeComponent()
'
' TODO: Add any constructor code after InitializeComponent call
'
Me.sqlSelectCommand1.Parameters.AddRange(New System.Data.SqlClient.SqlParameter() {New System.Data.SqlClient.SqlParameter("@user_id", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "user_id", System.Data.DataRowVersion.Current, userID)})
End Sub
End Class
Another possible solution is to prepare the report's data source from outside the report and pass it -- the Report.DataSource and Report.DataMember are public properties that you can use from outside.
Kind regards,
Svetoslav
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Me.textBox4.Value = "=data_nascimento" |
Can you help me?
Thanks again!
We will need some more information about the DateTime problem:
- Can you please explain in detail how exactly the DateTime fields are not working?
- Do you receive an error message/exception? If yes, please give us details on what the error says.
- If the report is rendered OK, what text is rendered from this TextBox instead of "1-1-2000"?
- Please verify that the exact type of the data field is DateTime.
You can format the value of a TextBox item using its Format property. Provide format string as you're using the String.Format() method. For example, to display the long string representation of the DateTime field you can use the next format string:
dateTextBox.Format = "{0:D}"
We recommend you to download and install the latest Service Pack 1 of the Telerik Reporting - v1.1. We made several tests with different format strings and data (including DBNull-s) and as of now we haven't got any problems.
Kind regards,
Svetoslav
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

- I can't get the results that are stored in the DB. The varchar fields work fine.
- No. No error messages
- Everything is rendered OK, except the text of TextBox4. The text showed is "=data_dascimento" (exactly the name of the field I want to get the data from.
- It's a datetime of SQL Server 2005...
Please verify whether the value of TextBox4 starts with one or more white spaces before the '=' character.
The TextBox binding works this way:
- if the Value is string it checks the 1st character for the '=' - if it starts with '=' this string is interpreted as a binding expression; otherwise it is rendered as is
- if the Value is other than a string object (and not null/Nothing) - the result of Value.ToString() is displayed.
From the additional info you have sent it seems that the Value is not processed as a binding expression so I suppose that there is a leading space that you should delete.
Best wishes,
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

the value of TextBox4 doesn't start with one or more white spaces before the '=' character, but I solved my problem installing SP1.
Thanks for the help.

Public Sub New(ByVal userID As String)
... code
End Sub
Thanks
The only way to use a report with constructor with parameters is to create it by yourself and to pass it to the report viewer. The reason is that the VisualStudio designer and the default code generation algorithm know only how to use the default constructor for a class that has no parameters , which is not your case.
Regards,
Svetoslav
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Thanks for the quick response!!
I know how to create the constructor that accepts an input value, but what code would I use in the viewer to call the constructor with an input value?
You have to instantiate the report class in exactly the same way as you would do with any other class, and then pass the instance to the report viewer:
Dim userID as Integer = 123
reportViewer1.Report = new MyReport(userID)
All the best,
Svetoslav
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Dim reportName As String = "AppReport, App_Code.86ajnlir, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
Dim reportType As Type = Type.[GetType](reportName)
Dim report As Report = DirectCast(Activator.CreateInstance(reportType), Report)
Me.vwrMain.Report = report
Me.Page.Title = "telerik Report Viewer - " + reportType.Name
You can use another overload of the CreateInstance method of the Activator class to achieve the desired result. To learn more about the Activator class you can take a glance at the following article.
Sincerely yours,
Chavdar
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center