如何在devexpress报告中传递参数

时间:2012-10-03 09:00:15

标签: devexpress parameter-passing xtrareport

我在Windows应用程序中使用Devexpress XtraReport进行报告。我在我的XtraReport1中设置了一个参数param1,其中包含string作为类型,并使用以下代码传递参数。

private void button1_Click(object sender, EventArgs e)        
{
    XtraReport1 report = new XtraReport1();            
    report.Parameters["param1"].Value = "kashif";
    report.Print();
}

当我按下按钮1时,下面的窗口出现并询问我已经在其中显示“kashif”的param1值,并带有“Submit”和“Reset”按钮 我的问题是:当我按下button1而不想直接传递“kashif”而不提示我输入param1值时,我不希望这个窗口被打开。 testimage

2 个答案:

答案 0 :(得分:12)

从他们的文档如何:Silently Pass a Parameter Value

Add a parameter to a report, set the parameter's Modifiers property to Public, and disable the parameter's Parameter.Visible property. When there are no visible parameters in a report, their values are passed "silently" (without exposing the Parameters UI to end-users).

private void button1_Click(object sender, EventArgs e) 
{
    // Create a report instance.
    XtraReport1 report = new XtraReport1();

    // Obtain a parameter, and set its value.
    report.parameter1.Value = 30;

    // Hide the Parameters UI from end-users.
    report.parameter1.Visible = false;

    // Show the report's print preview.
    report.ShowPreview();
}

答案 1 :(得分:0)

你可以这样 **(Asp.net Mvc Razor)

Invoice report = new Invoice();

public ActionResult InvoiceViewerPartial() {
using (CrmDbContext db = new CrmDbContext()) {
    report.DataSource = db.InvoiceItem.ToList();
}
    report.Parameters["InvoiceId"].Value = "Inv0003";                
    return PartialView("_InvoiceViewerPartial", report);
}