HTML5 Report Viewer load DataSet on codebehind

7 posts, 0 answers
  1. Josue
    Josue avatar
    8 posts
    Member since:
    Jan 2016

    Posted 30 May Link to this post

    Hello,

    it's possible load a dataset to report in HTML5 Report Viewer from codebehind?

    I'm search for this information but i can't find nothing.

    In my application i have a aspx with HTML5 Report Viewer and a Report.vb, the report vb contains into a dataset with 3 datatables, but i can't load the data to these dataset.

    PD: sorry if my english is a little bad, i speak a little english.

    Thank you for your attention and help

  2. Stef
    Admin
    Stef avatar
    3049 posts

    Posted 31 May Link to this post

    Hi Josue,

    In general, the purpose of the ObjectDataSource component is to provide data to the report in a declarative manner. The ObjectDataSource.DataSource should be the assembly qualified name or Type of the data access layer (class), where the reporting engine will use System.Reflection to create the instance of the class (by using its default constructor) and to execute its method specified by the ObjectDataSource.DataMember.


    The ObjectDataSource and other data source components can load only one DataTable from the wrapped DataSet. If you create a model that exposes relations between the 3 data objects e.g. Entity Framework model, you can use the EntityDataSource component and the data-binding approach from How to Databind to Collection Properties.


    Other approach, for updating a report before displaying it, is to use a custom resolver for the Reporting REST service. Please consider the example in this forum post.

    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
  4. Josue
    Josue avatar
    8 posts
    Member since:
    Jan 2016

    Posted 31 May in reply to Stef Link to this post

    So i can't not implement this Example with a HTML5 Report?

    In my app i have a one dataset with three tables (DatosGenerales, ResumenReferencias, ReferenciasActivas), and the report have one dataobject by each table.

    my report is type .vb

    Apologies for my english

  5. Josue
    Josue avatar
    8 posts
    Member since:
    Jan 2016

    Posted 31 May in reply to Josue Link to this post

    I'm Get the Error: Value of type 'Telerik.Reporting.InstanceReportSource' cannot be converted to 'Telerik.ReportViewer.Html5.WebForms.ReportSource'.  in My app with the example.

    this my code:

    01.Dim ds As New ReporteHistorialCliente.DatosGeneralesDataTable
    02. 
    03.ds.Rows.Add("JHON", "DOE", "0-509-1938", "15/12/2010", "APC BURÓ S.A.", "")
    04. 
    05.Dim objDS As New Telerik.Reporting.ObjectDataSource()
    06. 
    07.objDS.DataSource = ds
    08. 
    09.rptviewerHC.ReportSource = reportSource
  6. Josue
    Josue avatar
    8 posts
    Member since:
    Jan 2016

    Posted 31 May Link to this post

    Why i Can't edit or delete my answers, i publish the code with a error... and need edit de answer.
  7. Katia
    Admin
    Katia avatar
    308 posts

    Posted 03 Jun Link to this post

    Hi Josue,

    The approach described in How to: Bind to a DataSet suggests how to bind the DataItem to a single DataTable from your DataSet as ObjectdataSourceComponents allows to load only one DataTable from the DataSet.
    If this is not suitable in your scenario you can test the approach mentioned in my colleague's post (use EntityDataSource component) or add more DataItems and bind each one to a separate DataTable.

    The error message appears because HTML5 WebForms report viewer can only work with TypeReportSource and UriReportSource.
    HTML5 Viewer and Reporting REST service use a client-server model where the client sends short string descriptions (messages) to the server and gets content(report) from the server. The viewer(client) can only send a short description of the report (its assembly qualified name) or a path to the file on the server. The string description is interpreted by the service's report resolver which returns a ReportSource object.
    When you try to pass report instance (InstanceReportSource) an error will occur as report instances cannot be transferred in a message.
    Thus, you need to use TypeReportSource or UriReportSource to set viewer's source, or implement a custom report resolver to handle the resolve process yourself.


    Regards,
    Katia
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. Josue
    Josue avatar
    8 posts
    Member since:
    Jan 2016

    Posted 03 Jun Link to this post

    Hi,

    Thanks for your's answers, i can solved my problem

    in the load of my aspx i put this code:

    reportSource.Identifier = GetType(rptHistCliente).AssemblyQualifiedName
    reportSource.Parameters.Add("identClie", identClie)
    reportSource.Parameters.Add("tipoClie", tipoClie)
    reportSource.Parameters.Add("usuario", usuario)
    reportSource.Parameters.Add("identAsoc", identAsoc)
    Me.rptviewerHC.ReportSource = reportSource

    And did a class called ReportManager.vb with the methods to fill my rptHistCliente.vb, when the report is loading then databind the methods and fill the tables in the report.

    The methods return IEnumerable(Of typeOfClass), example:

    Public Function GetDatosGenerales(identClie As String, tipoClie As String) As IEnumerable(Of DatosGenerales)

     

    Thanks for your  Help

    regards

Back to Top
DevCraft banner