locked
Sql Reports and ASP .Net RRS feed

  • Question

  • I have a web site created with ASP .Net. I have a few textboxes and other controls with info displayed. What i would like to do is pass these variables into a report so it could be displayed.

    I believe i can do this in Visual Studio 2010 by dragging a ReportViewer from the toolbox or i can pass the control values into a report that has already been hosted on our SQL server 2008 R2 version.

    Im not sure which way i should create this report as im not 100% of all the cons and pros for each way. Could someone provide me some guidance in how to pass in variables into a report already hosted on our server or whether creating the report within VS 2010 using the ReportViewer control is the way?

    Thanks

    Thursday, August 9, 2012 6:03 PM

Answers

  • Hello Pure Deal,

    Thank you to post your question on TechNet forum.

    From your description, I think the current scenario is that we have some textboxes controls, which stores the values for a hosted report, and we do not want to create extra report and pass the value to load a hosted report with proper parameter value. If I misunderstand your requirement, please correct me freely.

    Based on the above scenario, we can add the custom code to set the parameters of the report and hide the parameter bar of the report to achieve this goal. Here is the segment of the code of loading the report.

    ReportParameter[] parameters = new ReportParameter[1];
    parameters[0] = new ReportParameter("Name", "Value");
    
    // Add more parameters...
    
    reportViewer1.ServerReport.SetParameters(parameters);
    

    If you want to hide the parameter bar, please use the following statement.

    reportViewer1.ShowParameterPrompts = false;

    For more information about this issue, please review the following MSDN article.

    http://msdn.microsoft.com/en-US/library/ms252178(v=vs.100)
    http://msdn.microsoft.com/en-us/library/microsoft.reporting.webforms.reportviewer.showparameterprompts(v=vs.80).aspx

    I hope it is helpful to you.

    Regards,

    Edward


    Edward Zhu

    TechNet Community Support

    • Proposed as answer by Edward Zhu Thursday, August 16, 2012 9:00 AM
    • Marked as answer by Edward Zhu Thursday, August 16, 2012 9:00 AM
    Friday, August 10, 2012 8:48 AM