vrathaure
03-28-2008, 03:06 AM
Hi all,
I m using visual studio 2005 n I want to view a crystal report (rpt) on an aspx page without having to log on and pass parameters through the crystal report's default way.
I have 2 variable that I am populating thru the drop down lists, but I am not able to apply those parameter fields to my current report.
The code that I am using is as below:-
protected void btnShowReport_Click(object sender, EventArgs e)
{
CrystalDecisions.Shared.ParameterField PARAMETER_FIELD_Cat = new CrystalDecisions.Shared.ParameterField();
CrystalDecisions.Shared.ParameterField PARAMETER_FIELD_SKU = new CrystalDecisions.Shared.ParameterField();
PARAMETER_FIELD_Cat.Name = "CategoryName";
PARAMETER_FIELD_SKU.Name = "SKUName";
CrystalDecisions.Shared.ParameterDiscreteValue PARAMETER_Discrete_FIELD_Cat = new ParameterDiscreteValue();
CrystalDecisions.Shared.ParameterDiscreteValue PARAMETER_Discrete_FIELD_SKU = new ParameterDiscreteValue();
PARAMETER_Discrete_FIELD_Cat.Value = ddlItems.SelectedItem.Text.ToString();
PARAMETER_Discrete_FIELD_SKU.Value = ddlSKUs.SelectedItem.Text.ToString();
PARAMETER_FIELD_Cat.CurrentValues.Add(PARAMETER_Discrete_FIELD_Cat);
PARAMETER_FIELD_SKU.CurrentValues.Add(PARAMETER_Discrete_FIELD_SKU);
CrystalDecisions.Shared.ParameterFields PARAMETER_FIELDs = new ParameterFields();
PARAMETER_FIELDs.Add(PARAMETER_FIELD_Cat);
PARAMETER_FIELDs.Add(PARAMETER_FIELD_SKU);
CrystalReportViewer1.ParameterFieldInfo = PARAMETER_FIELDs;
//code to log on to the db server
string reportPath = Server.MapPath("RPT_PriceDissemination.rpt");
ReportDocument myReportDocument = new ReportDocument();
myReportDocument.Load(reportPath);
myReportDocument.SetDatabaseLogon("<username>", "<password>");
//********
CrystalReportViewer1.ReportSource = myReportDocument;
// CrystalReportViewer1.ReportSource = "RPT_PriceDissemination.rpt";
CrystalReportViewer1.RefreshReport();
}
But it doesn't seem to work as desired.
I want to view the resulting report on button click, depending on my selections in the drop down list.
Please try and help me find the mistake that I m doing here.
Thanks in advance.
Regards
veegrl
I m using visual studio 2005 n I want to view a crystal report (rpt) on an aspx page without having to log on and pass parameters through the crystal report's default way.
I have 2 variable that I am populating thru the drop down lists, but I am not able to apply those parameter fields to my current report.
The code that I am using is as below:-
protected void btnShowReport_Click(object sender, EventArgs e)
{
CrystalDecisions.Shared.ParameterField PARAMETER_FIELD_Cat = new CrystalDecisions.Shared.ParameterField();
CrystalDecisions.Shared.ParameterField PARAMETER_FIELD_SKU = new CrystalDecisions.Shared.ParameterField();
PARAMETER_FIELD_Cat.Name = "CategoryName";
PARAMETER_FIELD_SKU.Name = "SKUName";
CrystalDecisions.Shared.ParameterDiscreteValue PARAMETER_Discrete_FIELD_Cat = new ParameterDiscreteValue();
CrystalDecisions.Shared.ParameterDiscreteValue PARAMETER_Discrete_FIELD_SKU = new ParameterDiscreteValue();
PARAMETER_Discrete_FIELD_Cat.Value = ddlItems.SelectedItem.Text.ToString();
PARAMETER_Discrete_FIELD_SKU.Value = ddlSKUs.SelectedItem.Text.ToString();
PARAMETER_FIELD_Cat.CurrentValues.Add(PARAMETER_Discrete_FIELD_Cat);
PARAMETER_FIELD_SKU.CurrentValues.Add(PARAMETER_Discrete_FIELD_SKU);
CrystalDecisions.Shared.ParameterFields PARAMETER_FIELDs = new ParameterFields();
PARAMETER_FIELDs.Add(PARAMETER_FIELD_Cat);
PARAMETER_FIELDs.Add(PARAMETER_FIELD_SKU);
CrystalReportViewer1.ParameterFieldInfo = PARAMETER_FIELDs;
//code to log on to the db server
string reportPath = Server.MapPath("RPT_PriceDissemination.rpt");
ReportDocument myReportDocument = new ReportDocument();
myReportDocument.Load(reportPath);
myReportDocument.SetDatabaseLogon("<username>", "<password>");
//********
CrystalReportViewer1.ReportSource = myReportDocument;
// CrystalReportViewer1.ReportSource = "RPT_PriceDissemination.rpt";
CrystalReportViewer1.RefreshReport();
}
But it doesn't seem to work as desired.
I want to view the resulting report on button click, depending on my selections in the drop down list.
Please try and help me find the mistake that I m doing here.
Thanks in advance.
Regards
veegrl