none
Textbox values to a Report RRS feed

  • Question

  • I want to make a report based on values in texboxes in a form and then display the report through Report Viewer

    it is for creating printable Invoice

    so how can i take those values to the report? 

    • Moved by Lie You Thursday, July 21, 2011 6:40 AM Report Controls related (From:Visual C# General)
    Tuesday, July 19, 2011 4:50 PM

Answers

  • YOu can create a report using DataSet (or DataTable). Check for solution here.

    How to do it: Create a DataTable, with two column (one for description, another one for the values from textBoxes). Then create an array of all textBoxes, and loop through this array to add rows to dataTable. Then you create a new insance of Form2 and pass dataTable to the constructor of form2. Use the code from upper link to connect dataTable to reports.


    Mitja
    • Marked as answer by Md.Ibrahim Thursday, April 12, 2012 5:51 AM
    Tuesday, July 19, 2011 9:14 PM

All replies

  • Hi

    you can use this

    http://stackoverflow.com/questions/5987168/passing-a-value-from-a-form-to-a-report

    http://www.barakasoft.com/vb/showthread.php?39583-Passing-a-Varible-to-a-TextBox-in-ReportViewer

    http://www.bigresource.com/MS_SQL-Read-textbox-value-from-reportviewer-dhoRtc4K.html

     


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    i can't fully understand the first example

    could u please summarize the steps to link 1?

    the next two are obselete

    Tuesday, July 19, 2011 7:12 PM
  • Hi

    1) add new parameter to your report

    2) use this code to put text from your textbox  to this parameter

    ReportViewer.SetQueryParameter("ParameterName",Textbox.Text);


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Tuesday, July 19, 2011 7:57 PM
  • Hi

    1) add new parameter to your report

    2) use this code to put text from your textbox  to this parameter

    ReportViewer.SetQueryParameter("ParameterName",Textbox.Text);


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    but there are two forms

    in which form do i use the code and how will form2(form with report viewer) be able to get the textbox value of form 1(where the textbox resides) ?

    Tuesday, July 19, 2011 9:04 PM
  • YOu can create a report using DataSet (or DataTable). Check for solution here.

    How to do it: Create a DataTable, with two column (one for description, another one for the values from textBoxes). Then create an array of all textBoxes, and loop through this array to add rows to dataTable. Then you create a new insance of Form2 and pass dataTable to the constructor of form2. Use the code from upper link to connect dataTable to reports.


    Mitja
    • Marked as answer by Md.Ibrahim Thursday, April 12, 2012 5:51 AM
    Tuesday, July 19, 2011 9:14 PM
  • YOu can create a report using DataSet (or DataTable). Check for solution here.

    How to do it: Create a DataTable, with two column (one for description, another one for the values from textBoxes). Then create an array of all textBoxes, and loop through this array to add rows to dataTable. Then you create a new insance of Form2 and pass dataTable to the constructor of form2. Use the code from upper link to connect dataTable to reports.


    Mitja

    can't the data passing be done through interfaces?

    and could u link to me some example that shows how to get textbox values in a dataset?

    i can't find any solid examples relevant to my problem

    Wednesday, July 20, 2011 10:42 AM
  • hi n00b_muscle

    most report designers supports some sort of parameters witch you can pass a value to, in some others (like ComponentOne report) you can access and change the value of text boxes directly  . so the answer depends on the type of report maker you're going to use. if you're using Microsoft reporting or crystal reports then you have to define a report parameter for each value you're going to pas to it . this way you can bind the text boxes in your report to a parameter and pass your desired values to that parameter in your code.

    Wednesday, July 20, 2011 10:56 AM
  • hi n00b_muscle

    most report designers supports some sort of parameters witch you can pass a value to, in some others (like ComponentOne report) you can access and change the value of text boxes directly  . so the answer depends on the type of report maker you're going to use. if you're using Microsoft reporting or crystal reports then you have to define a report parameter for each value you're going to pas to it . this way you can bind the text boxes in your report to a parameter and pass your desired values to that parameter in your code.

    i appreciate what u guys have been trying to explain

    but i'm new to reporting

    and i can't really understand what u guys means without some code examples

    so it'd be really helpful if u guys can provide some examples

    Wednesday, July 20, 2011 2:50 PM
  • Hello n00b_muscle,

    Welcome to the MSDN Forum.

    For Report Viewer issue, I suggest you post it to the more appropriate for more efficient responses, such as: Visual Studio Report Controls Forum.

    I will help you to move this case to that Forum this time.

    Thanks for your understanding and support.


    Best Regards,
    Rocky Yue[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, July 21, 2011 6:40 AM
  •  

    Hello n00b_muscle,

     

    Welcome to the MSDN Forum.

     

    For Report Viewer issue, I suggest you post it to the more appropriate for more efficient responses, such as: Visual Studio Report Controls Forum.

     

    I will help you to move this case to that Forum this time.

     

    Thanks for your understanding and support.

     


    Best Regards,
    Rocky Yue[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    thank you and sorry.
    Thursday, July 21, 2011 10:03 AM