Hi All, I am currently passing parameters (all blank strings right now except Offices to a Crystal Reports Viewer. The Crystal Reports Viewer will not refresh or even recognize that anything has changed. I am currently using VS 2005 and here is my code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.Web;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
public partial class Test3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
CrystalReportViewer1.LogOnInfo[0].ConnectionInfo.ServerName = ".";
CrystalReportViewer1.LogOnInfo[0].ConnectionInfo.UserID = "Kyle";
CrystalReportViewer1.LogOnInfo[0].ConnectionInfo.Password = "";
CrystalReportViewer1.LogOnInfo[0].ConnectionInfo.DatabaseName = "ISLDB";
CrystalReportViewer1.ReportSource = CrystalReportSource1;
if (!Page.IsPostBack)
{
//Load The Drop Down Lists
LoadOffices();
LoadBoxTypes();
LoadStatus();
ReportParameter();
}
}
protected void LoadOffices()
{
DataSet officeDS = new DataSet();
try
{
ISL_System.ISL controller = new ISL_System.ISL();
officeDS = controller.LookUpOfficeList();
DataRow blankRow = officeDS.Tables["OfficeDS"].NewRow();
blankRow["OfficeDescription"] = "";
blankRow["OfficeKey"] = 0;
officeDS.Tables["OfficeDS"].Rows.Add(blankRow);
officeDS.Tables["OfficeDS"].DefaultView.Sort = "OfficeDescription ASC";
ddlOfficeList.DataSource = officeDS.Tables["OfficeDS"];
ddlOfficeList.DataTextField = "OfficeDescription";
ddlOfficeList.DataValueField = "OfficeKey";
ddlOfficeList.DataBind();
}
catch (Exception ex)
{
lblMessage.Text = "error loading Offices" + ex.Message;
}
}
protected void LoadBoxTypes()
{
DataSet BoxTypeDS = new DataSet();
try
{
ISL_System.ISL controller = new ISL_System.ISL();
BoxTypeDS = controller.LookUpBoxTypeList();
DataRow blankRow = BoxTypeDS.Tables["BoxTypeDS"].NewRow();
blankRow["BoxTypeDescription"] = "";
blankRow["BoxTypeKey"] = 0;
BoxTypeDS.Tables["BoxTypeDS"].Rows.Add(blankRow);
BoxTypeDS.Tables["BoxTypeDS"].DefaultView.Sort = "BoxTypeDescription ASC";
ddlBoxTypeList.DataSource = BoxTypeDS.Tables["BoxTypeDS"];
ddlBoxTypeList.DataTextField = "BoxTypeDescription";
ddlBoxTypeList.DataValueField = "BoxTypeKey";
ddlBoxTypeList.DataBind();
}
catch (Exception ex)
{
lblMessage.Text = "error loading Box Types" + ex.Message;
}
}
protected void LoadStatus()
{
DataSet StatusDS = new DataSet();
try
{
ISL_System.ISL controller = new ISL_System.ISL();
StatusDS = controller.LookUpStatusList();
DataRow blankRow = StatusDS.Tables["StatusDS"].NewRow();
blankRow["StatusDescription"] = "";
blankRow["StatusKey"] = 0;
StatusDS.Tables["StatusDS"].Rows.Add(blankRow);
StatusDS.Tables["StatusDS"].DefaultView.Sort = "StatusDescription ASC";
ddlStatusList.DataSource = StatusDS.Tables["StatusDS"];
ddlStatusList.DataTextField = "StatusDescription";
ddlStatusList.DataValueField = "StatusKey";
ddlStatusList.DataBind();
}
catch (Exception ex)
{
lblMessage.Text = "error loading Status drop down list" + ex.Message;
}
}
private void ReportParameter()
{
CrystalReportViewer1.RefreshReport();
ParameterFields paramFields = new ParameterFields();
//Project Number parameter
ParameterField ProjectNumber = new ParameterField();
ProjectNumber.ParameterFieldName = "ProjectNumber"; //project number is Crystal Report Parameter name.
ParameterDiscreteValue dcProjectNumber = new ParameterDiscreteValue();
dcProjectNumber.Value = "";
ProjectNumber.CurrentValues.Add(dcProjectNumber);
paramFields.Add(ProjectNumber);
//Office Parameter
int intOffice = ddlOfficeList.SelectedIndex;
ParameterField Office = new ParameterField();
Office.ParameterFieldName = "Office"; //project number is Crystal Report Parameter name.
ParameterDiscreteValue dcOffice = new ParameterDiscreteValue();
dcOffice.Value = ddlOfficeList.SelectedItem.Text;//ddlOfficeList.SelectedValue;
Office.CurrentValues.Add(dcOffice);
paramFields.Add(Office);
//Box Type Parameter
ParameterField BoxType = new ParameterField();
BoxType.ParameterFieldName = "BoxType"; //project number is Crystal Report Parameter name.
ParameterDiscreteValue dcBoxType = new ParameterDiscreteValue();
dcBoxType.Value = "";
BoxType.CurrentValues.Add(dcBoxType);
paramFields.Add(BoxType);
//Box Number Parameter
ParameterField BoxNumber = new ParameterField();
BoxNumber.ParameterFieldName = "BoxNumber"; //project number is Crystal Report Parameter name.
ParameterDiscreteValue dcBoxNumber = new ParameterDiscreteValue();
dcBoxNumber.Value = "";
BoxNumber.CurrentValues.Add(dcBoxNumber);
paramFields.Add(BoxNumber);
//Status Parameter
ParameterField Status = new ParameterField();
Status.ParameterFieldName = "Status"; //project number is Crystal Report Parameter name.
ParameterDiscreteValue dcStatus = new ParameterDiscreteValue();
dcStatus.Value = "";
Status.CurrentValues.Add(dcStatus);
paramFields.Add(Status);
CrystalReportViewer1.ParameterFieldInfo = paramFields;
}
protected void btnGenerateArchivedProjectReport_Click(object sender, EventArgs e)
{
ReportParameter();
lblMessage.Text = "Report Submitted";
}
}
Let me know if I can provide any more details.
Thanks,
Tony
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.Web;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
public partial class Test3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
CrystalReportViewer1.LogOnInfo[0].ConnectionInfo.ServerName = ".";
CrystalReportViewer1.LogOnInfo[0].ConnectionInfo.UserID = "Kyle";
CrystalReportViewer1.LogOnInfo[0].ConnectionInfo.Password = "";
CrystalReportViewer1.LogOnInfo[0].ConnectionInfo.DatabaseName = "ISLDB";
CrystalReportViewer1.ReportSource = CrystalReportSource1;
if (!Page.IsPostBack)
{
//Load The Drop Down Lists
LoadOffices();
LoadBoxTypes();
LoadStatus();
ReportParameter();
}
}
protected void LoadOffices()
{
DataSet officeDS = new DataSet();
try
{
ISL_System.ISL controller = new ISL_System.ISL();
officeDS = controller.LookUpOfficeList();
DataRow blankRow = officeDS.Tables["OfficeDS"].NewRow();
blankRow["OfficeDescription"] = "";
blankRow["OfficeKey"] = 0;
officeDS.Tables["OfficeDS"].Rows.Add(blankRow);
officeDS.Tables["OfficeDS"].DefaultView.Sort = "OfficeDescription ASC";
ddlOfficeList.DataSource = officeDS.Tables["OfficeDS"];
ddlOfficeList.DataTextField = "OfficeDescription";
ddlOfficeList.DataValueField = "OfficeKey";
ddlOfficeList.DataBind();
}
catch (Exception ex)
{
lblMessage.Text = "error loading Offices" + ex.Message;
}
}
protected void LoadBoxTypes()
{
DataSet BoxTypeDS = new DataSet();
try
{
ISL_System.ISL controller = new ISL_System.ISL();
BoxTypeDS = controller.LookUpBoxTypeList();
DataRow blankRow = BoxTypeDS.Tables["BoxTypeDS"].NewRow();
blankRow["BoxTypeDescription"] = "";
blankRow["BoxTypeKey"] = 0;
BoxTypeDS.Tables["BoxTypeDS"].Rows.Add(blankRow);
BoxTypeDS.Tables["BoxTypeDS"].DefaultView.Sort = "BoxTypeDescription ASC";
ddlBoxTypeList.DataSource = BoxTypeDS.Tables["BoxTypeDS"];
ddlBoxTypeList.DataTextField = "BoxTypeDescription";
ddlBoxTypeList.DataValueField = "BoxTypeKey";
ddlBoxTypeList.DataBind();
}
catch (Exception ex)
{
lblMessage.Text = "error loading Box Types" + ex.Message;
}
}
protected void LoadStatus()
{
DataSet StatusDS = new DataSet();
try
{
ISL_System.ISL controller = new ISL_System.ISL();
StatusDS = controller.LookUpStatusList();
DataRow blankRow = StatusDS.Tables["StatusDS"].NewRow();
blankRow["StatusDescription"] = "";
blankRow["StatusKey"] = 0;
StatusDS.Tables["StatusDS"].Rows.Add(blankRow);
StatusDS.Tables["StatusDS"].DefaultView.Sort = "StatusDescription ASC";
ddlStatusList.DataSource = StatusDS.Tables["StatusDS"];
ddlStatusList.DataTextField = "StatusDescription";
ddlStatusList.DataValueField = "StatusKey";
ddlStatusList.DataBind();
}
catch (Exception ex)
{
lblMessage.Text = "error loading Status drop down list" + ex.Message;
}
}
private void ReportParameter()
{
CrystalReportViewer1.RefreshReport();
ParameterFields paramFields = new ParameterFields();
//Project Number parameter
ParameterField ProjectNumber = new ParameterField();
ProjectNumber.ParameterFieldName = "ProjectNumber"; //project number is Crystal Report Parameter name.
ParameterDiscreteValue dcProjectNumber = new ParameterDiscreteValue();
dcProjectNumber.Value = "";
ProjectNumber.CurrentValues.Add(dcProjectNumber);
paramFields.Add(ProjectNumber);
//Office Parameter
int intOffice = ddlOfficeList.SelectedIndex;
ParameterField Office = new ParameterField();
Office.ParameterFieldName = "Office"; //project number is Crystal Report Parameter name.
ParameterDiscreteValue dcOffice = new ParameterDiscreteValue();
dcOffice.Value = ddlOfficeList.SelectedItem.Text;//ddlOfficeList.SelectedValue;
Office.CurrentValues.Add(dcOffice);
paramFields.Add(Office);
//Box Type Parameter
ParameterField BoxType = new ParameterField();
BoxType.ParameterFieldName = "BoxType"; //project number is Crystal Report Parameter name.
ParameterDiscreteValue dcBoxType = new ParameterDiscreteValue();
dcBoxType.Value = "";
BoxType.CurrentValues.Add(dcBoxType);
paramFields.Add(BoxType);
//Box Number Parameter
ParameterField BoxNumber = new ParameterField();
BoxNumber.ParameterFieldName = "BoxNumber"; //project number is Crystal Report Parameter name.
ParameterDiscreteValue dcBoxNumber = new ParameterDiscreteValue();
dcBoxNumber.Value = "";
BoxNumber.CurrentValues.Add(dcBoxNumber);
paramFields.Add(BoxNumber);
//Status Parameter
ParameterField Status = new ParameterField();
Status.ParameterFieldName = "Status"; //project number is Crystal Report Parameter name.
ParameterDiscreteValue dcStatus = new ParameterDiscreteValue();
dcStatus.Value = "";
Status.CurrentValues.Add(dcStatus);
paramFields.Add(Status);
CrystalReportViewer1.ParameterFieldInfo = paramFields;
}
protected void btnGenerateArchivedProjectReport_Click(object sender, EventArgs e)
{
ReportParameter();
lblMessage.Text = "Report Submitted";
}
}
Let me know if I can provide any more details.
Thanks,
Tony