Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

How to avoid Optional parameter prompt? I tried different methods. In my SP I have given default value as null for all the Parameters.

C#
InvoiceReport objReport = new InvoiceReport();
ReportDocument obj1 = new ReportDocument();
obj1.Load(@"C:\Projects\Restaurant.UI\InvoiceDetails.rpt");

if (rbInvoiceStatus.Checked == true)
{
    int statusid=Convert.ToInt32(cmbItems.SelectedValue.ToString());
    obj1.SetParameterValue("@InvoiceNo", DBNull.Value);
    obj1.SetParameterValue("@VendorID", DBNull.Value);
    obj1.SetParameterValue("@FromDate", DBNull.Value);
    obj1.SetParameterValue("@Todate", DBNull.Value);
    obj1.SetParameterValue("@InvoiceStatusID", statusid);
}
objReport.crystalReportViewer1.ReportSource = obj1;
objReport.Show();
Posted
Updated 18-Jan-13 5:01am
v2
Comments
The Doer 18-Jan-13 3:21am    
Please clarify your question more clearly , does it pop up some some parameters? Do you want to avoid those?

There're two prompts in Crystal reports,
1. Parameter prompt - Disabling Parameter Prompt Dialog Box in Crystal Reports For Visual Studio[^]
2. Logon prompt - C# Crystal Reports Dynamic Logon parameters[^]
 
Share this answer
 
Use the following code to set the parameter in code file

_objReportDocument = new ReportDocument();
_objReportDocument.SetParameterValue(paramName, paramValue);


then it will not prompt you to enter parameter
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900