将参数传递给reportviewer的查询

时间:2013-01-29 11:03:36

标签: asp.net visual-studio-2010 reportviewer

我的typed dataset上有用于填充ReportViewer

的查询
SELECT        proj.descricao AS projeto, func.descricao AS funcionalidade, clb.clube AS cliente, ch.descricao
FROM            chamados ch INNER JOIN
                         projetos proj ON ch.projeto = proj.id INNER JOIN
                         funcionalidades func ON ch.funcionalidade = func.id INNER JOIN
                         clubes clb ON ch.clube = clb.id
WHERE        (ch.responsavel = @responsavel) AND (ch.clube = @clube)

请参阅parameters @responsavel@clube?我现在想要如何从codebehind传递这些参数的值。谢谢 ! Obs:我知道如何在windowsForms中执行此操作,但是对于Web应用程序,它有所不同,我不知道它是如何工作的。

1 个答案:

答案 0 :(得分:1)

我刚刚找到解决方案 - 您需要参加ObjectDataSource1_Selecting活动。我使用Sessions将值传递到一个网页到另一个网页。 这是代码:

protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
            string usrValue = Session["usrValue"].ToString();
            string usrText = Session["usrText"].ToString();
            string cliente = Session["cliente"].ToString();

            e.InputParameters["responsavel"] = usrValue;
            e.InputParameters["clube"] = cliente;
        }