How we pass multiple values as dynamic parameter in Fast Report

Hi,

How we pass multiple values as parameter in Fast Report

I want to pass two value as report parameter , so that multiple record display.
Ex: We have 4 doctors in table

1-A
2-B
3-C
4-D

We have 5 Patient with associated doctors in patient table
1-A1-A
2-A2-A
3-A3-B
4-A4-C
5-A5-B


So i want to display the record for all patient which associated with A,B Doctor.
parameter code concatenate A,B but in report pass only B, So how we pass dynamically Parameter as A,B.

dynamicparameter = "A,B"

Report.SetParameterValue("code", dynamicparameter)

But if we pass parameter as below then result proper.
Report.SetParameterValue("code", "A,B")



Comments

  • edited October 2017
    https://www.fast-report.com/en/forum/index....c=14113&hl=


    you also may pass object in Report.SetParameterValue

    for example:

    in your app.exe
    namespace AppFastReport
    {
        public class MatrixDemo
        {
            public string Name { get; set; }
            public int Year { get; set; }
            public int Month { get; set; }
            public int ItemsSold { get; set; }
            public decimal Revenue { get; set; }
        }
    }
    

    passing object :
                MatrixDemo mdObject= new MatrixDemo();
                mdObject.Name = "Test Parameter";
                report.SetParameterValue("Code", mdObject);
    


    in your frx file
    you must set reference to app.exe and create script :
    using System;
    using FastReport;
    
    namespace FastReport
    {
      public class ReportScript
      {
    
        private void ReportTitle1_BeforePrint(object sender, EventArgs e)
        {
           AppFastReport.MatrixDemo a = Report.GetParameterValue("Code") as AppFastReport.MatrixDemo;
           Text1.Text = a.Name;
        }
      }
    }
    

  • loubet_danloubet_dan Mexico
    edited May 2018
    Ok but at design time there is no data type or what type of data would be placed
  • edited 6:24PM
    in app project, with a namespace = WindowsFormsApplication1, define a class:
    public class DataTransferObject
      {                 
        public int Id { get; set; }    
        public string Name { get; set; }
      }
    

    then pass :
    DataTransferObject parameter = new DataTransferObject() { Id = 1, Name = "Test" };
    report.SetParameterValue("Parameter", parameter);

    in frx file, define a parameter with name = 'Parameter' and datatype = null, then create a script:
    namespace FastReport
    {
      public class ReportScript
      {
    
        private void _StartReport(object sender, EventArgs e)
        {
          // USE AT DESIGN TIME
          DataTransferObject dto = new DataTransferObject() { Id = 1, Name = "Default"};
          Text1.Text = dto.Name;
    
          // USE AT RUN TIME
          //WindowsFormsApplication1.DataTransferObject param = Report.GetParameterValue("Parameter") as WindowsFormsApplication1.DataTransferObject; 
          //Text1.Text = param.Name;
        }
      }
      
      public class DataTransferObject
      {                 
        public int Id { get; set; }    
        public string Name { get; set; }
      }
    }
    


Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.