RDLC Report Viewer - 如何以编程方式重置输入参数

时间:2012-09-13 23:01:42

标签: asp.net webforms rdlc report-viewer2010

我的网站上有一个RDLC控件。这是客户端报告。我在Visual Studio 2010中使用ASP.net 3.5报告采用了许多过滤条件作为输入参数。存在生成结果的SQl服务器2008 R2存储过程。其中一个输入是具有相关日历控件的日期时间文本框。有一个“刷新”按钮。单击此按钮可刷新报告。我想为日期添加一些验证。我的所有验证工作正常。我的问题是,当用户在日期时间文本框中输入错误的字符时,报告失败,这是正确的,但是当用户点击刷新按钮时,虽然错误消失,但报告仍显示错误消息。

有没有办法在本地调用报表时刷新参数。 这是我的简单代码 -

    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 个答案:

答案 0 :(得分:0)

您可以将参数值设置为空白或以其他方式使用:

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