locked
How to call Parameters in Asp.Net Report viewer Control? RRS feed

  • Question

  • User1135748423 posted

    Hai 2 All,

    Am Creating A Drop down Control in asp.net , appended data bound items in that

    Using Folloeing Code: Aspx.cs file

    private void getUsers()
    {
    String _Constr = ConfigurationManager.ConnectionStrings["Db"].ConnectionString;
    using (SqlConnection con = new SqlConnection(_Constr))
    {
    con.Open();
    using (SqlCommand cmd = new SqlCommand("select Register_Id,(isnull (FirstName, ' ') +' ' +isnull (LastName, ' ')) As UserName from Registration"))
    {
    cmd.CommandType =CommandType.Text;

    try
    {
    cmd.Connection = con;
    getUsersDropDown.AppendDataBoundItems = true;
    getUsersDropDown.DataSource = cmd.ExecuteReader();
    getUsersDropDown.DataTextField ="UserName";
    getUsersDropDown.DataValueField ="Register_Id";
    getUsersDropDown.DataBind();
    }
    catch (Exception ex)
    {
    ex.ToString();
    }
    finally
    {
    con.Close();
    con.Dispose();
    }


    }

    }
    }

    now this parameters are passed in Report viewer Control in Asp.Net?

    Am writing the following code for calling the  SSRS Reports: here am i want to pass Register_Id parameter 


    UserWiseReportViewer.ProcessingMode = ProcessingMode.Remote;
    UserWiseReportViewer.SizeToReportContent = true;
    UserWiseReportViewer.ServerReport.ReportServerUrl = new Uri("http://192.168.1.12/ReportServer");
    UserWiseReportViewer.ServerReport.ReportPath = "/Reports/User Wise Report";
    UserWiseReportViewer.ServerReport.Refresh();

     

    Monday, January 5, 2015 3:30 AM

Answers

  • User1577371250 posted
    ReportParameter p = new ReportParameter("ShowDescriptions", checkBox1.Checked.ToString());
       this.reportViewer1.ServerReport.SetParameters(new ReportParameter[] { p });

    The above is used to pass the CheckBox value whether to show the Description is Report or not.

    Can you post the Error message?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 5, 2015 6:21 AM

All replies

  • User1577371250 posted
    ReportParameter[] parameters = new ReportParameter[1];
    parameters[0] = new ReportParameter("Register_Id", getUsersDropDown.SelectedValue);
    this.UserWiseReportViewer.LocalReport.SetParameters(parameters);

    More Information

    http://www.codeproject.com/Questions/614784/How-to-pass-paramenters-from-ReportViewer-control

    http://www.codeproject.com/Articles/15597/Using-the-ASP-NET-2-0-ReportViewer-in-Local-Mode

    Monday, January 5, 2015 4:05 AM
  • User1135748423 posted

    Is it Correct or not

    ServerReport serverreport = UserWiseReportViewer.ServerReport;
    UserWiseReportViewer.ProcessingMode = ProcessingMode.Remote;

    UserWiseReportViewer.SizeToReportContent =true;
    UserWiseReportViewer.ShowParameterPrompts =false;
    UserWiseReportViewer.ServerReport.ReportServerUrl = new Uri("http://192.168.1.12/ReportServer");
    UserWiseReportViewer.ServerReport.ReportPath = "/Reports/User Wise Report";
    ReportParameter register = new ReportParameter();
    register.Name = "UserName";

    register.Values.Add(getUsersDropDown.SelectedValue);
    UserWiseReportViewer.ServerReport.SetParameters(new ReportParameter[] { register });
    UserWiseReportViewer.Visible = true;
    UserWiseReportViewer.ServerReport.Refresh();

    Monday, January 5, 2015 4:47 AM
  • User1135748423 posted

    Am writing this but getting error 

    ServerReport serverreport = UserWiseReportViewer.ServerReport;
    UserWiseReportViewer.ProcessingMode = ProcessingMode.Remote;

    UserWiseReportViewer.SizeToReportContent =true;
    UserWiseReportViewer.ShowParameterPrompts =false;
    UserWiseReportViewer.ServerReport.ReportServerUrl = new Uri("http://192.168.1.12/ReportServer");
    UserWiseReportViewer.ServerReport.ReportPath = "/Reports/User Wise Report";
    ReportParameter register = new ReportParameter();
    register.Name = "UserName";

    register.Values.Add(getUsersDropDown.SelectedValue);
    UserWiseReportViewer.ServerReport.SetParameters(new ReportParameter[] { register });
    UserWiseReportViewer.Visible = true;
    UserWiseReportViewer.ServerReport.Refresh();

    Monday, January 5, 2015 5:55 AM
  • User1577371250 posted
    ReportParameter p = new ReportParameter("ShowDescriptions", checkBox1.Checked.ToString());
       this.reportViewer1.ServerReport.SetParameters(new ReportParameter[] { p });

    The above is used to pass the CheckBox value whether to show the Description is Report or not.

    Can you post the Error message?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 5, 2015 6:21 AM