0
votes

I have a RDLC control on my website. This is client side report. I am using ASP.net 3.5 with Visual Studio 2010 There are a number of filtering criteria which the report takes as the input parameters. There is a SQl server 2008 R2 Stored Procedure which generates the results. One of the inputs is a datetime textbox with associated calendar control. There is a 'Refresh' button. Clicking this refreshes the report. I wanted to add some validations for date. All my validations work fine. My issue is when a user enters wrong characters in the datetime textbox, the report fails which is correct but when the user hits refresh button though the error vanishes the report still displays the error message.

Is there a way to refresh the parameters when locally calling the report. This is my simple code -

    protected void BtnRefresh_Click(object sender, EventArgs e)
    {
        //check object session
        LoginSessionData.IsValid();

        //Hide the display panel 
        DisplayMessage.Visible = false;

        //add a try catch block here
        try
        {

            ReportViewer1.LocalReport.Refresh();
        }
        catch (Exception ex)
        {
            m_logger.Error(ex);
        }
    }

enter image description here

1

1 Answers

0
votes

You can set parameter values to blank or otherwise using this:

ReportParameter p1 = new 
      ReportParameter("ShowDescriptions", checkBox1.Checked.ToString());
ReportParameter p2 = new 
      ReportParameter("MyDate", DateTime.Now.ToString());
ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1, p2 });