none
How to add data to the reportviewer from textbox? RRS feed

  • Question

  •  

    Good days!

    I need for help about reportviwer Smile

     

    How to add data from textbox to reportviewer?

    For example: Form has got a Textbox1, on the same Form there is reportviewer.

    How can I transmit data (string data from Textbox1.Text)  to reportviwer?

     

    Thanks

    Wednesday, March 12, 2008 1:43 PM

All replies

  • first, in your report that you want to use this value from the textbox...you'll need to create a parameter

     

    open your report in the report designer, right click the blank area, and choose parameters.  Setup your parameter as a string, and give it an intuitive name

     

    In our example well call it "Param1"

     

    then, on your form that has the reportviewer, do the following

     

    ReportParameter firstParam = new ReportParameter("Param1", Textbox1.Text);

    ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { firstParam});

     

     

    in your report. in order to call the parameter's value you need to use the following expression

     

     

    Parameters!Param1.Value

    Wednesday, March 12, 2008 7:02 PM
  •  

    Thank you, Blast2hell!

     

    You advice is helpful, and I see the way to solve my project.

     

    But I have faced difficulties: Error List shows the error "Param1 has a DefaultValue or ValidValue that depends on the report parameter Param1",  and during processing there is message "The Param1 parameter is missing a value" on the ReportViewer1.

     

    The project's code (VB):

    Dim firstParam As ReportParameter = New ReportParameter("Param1", TextBox1.Text)

    ReportViewer1.LocalReport.SetParameters(New ReportParameter() {firstParam})

     

    What is wrong?

     

    Thursday, March 13, 2008 11:37 AM
  • Your vb code looks fine.....is this an .RDLC file?

    And what are you using this parameter for?

    Thursday, March 13, 2008 1:36 PM
  •  

    yes it is... Report1.RDLC

     

    perhaps, I made mistake in this an RDLC file?

    I chose "Report Parameter">>set Param1>>Properties: Name=Param1, Promt=Param1, Default Value=Parameters!Param1.Value...

     

    Thursday, March 13, 2008 3:41 PM
  • So, I removed expression=Parameters!Param1.Value, set DefaultValue=0 and there is no

    error "Param1 has a DefaultValue or ValidValue that depends on the report parameter Param"! as result.

     

    good.

     

    But "The Param1 parameter is missing a value" on the ReportViewer1 is still visible

     

    Thursday, March 13, 2008 4:05 PM
  • yeah, under properties for the parameter try setting them up like this

     

     

    Name:  Param1

    DataType: String

    Prompt: Param1  (prompts aren't used in .RDLC, so not really a concern)

    Default Value:   null  (just check the null box)

     

     

     

    Parameters!Param1.Value  is what you use in the report to call the value to a control in the report, it's not a default value

    Thursday, March 13, 2008 5:06 PM
  • there is a good result here!

     

    The Report runs normally Smile

     

    Thank you very much!

    Friday, March 14, 2008 4:16 AM