how to pass parameter in devexpress report

女生的网名这么多〃 提交于 2019-12-01 05:22:25

问题


I am using Devexpress XtraReport in Windows application for reporting purpose. I have set a parameter param1 having string as type in my XtraReport1 and using following code to pass parameter.

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

when I press button1 the following windows apperas and ask me for param1 values having already displayed "kashif" in it with button "Submit" and "Reset" My Problem is: I don't want this window to get opened when i Press button1 rather I want to pass directly "kashif" in it without prompting me for param1 value.


回答1:


From their documentation here How To: 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();
}



回答2:


You can like this ** (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);
}


来源:https://stackoverflow.com/questions/12705080/how-to-pass-parameter-in-devexpress-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!