在Crystal Report中输入值时出现问题 [英] Having an issue with Enter values in Crystal Report

查看:94
本文介绍了在Crystal Report中输入值时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含Crystal Report查看器的Web表单。报告显示但您必须输入ID号。我也有一个文本框。文本框从会话中填充用户的ID号。如何从文本框中获取ID以显示报告而无需用户输入?



I have a web form that has Crystal Report viewer on it. The report shows but you will have to enter the ID number. I also have a textbox in place. The textbox populates the ID number for the user from the session. How can I get the ID from the textbox to display the report without the user entering it?

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using CrystalDecisions.Web;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Windows;
using CrystalDecisions.ReportSource;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Xml.Linq;
using System.Web.SessionState;


namespace SACSCOCLogin1._1
{
    public partial class ReportA : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            TextBoxINST_ID.Text = Session["inst_id"].ToString();
            CrystalReportViewer1.Visible = true;

            ReportDocument CrystalReport = new ReportDocument();
            ParameterField paramField = new ParameterField();
            ParameterFields paramFields = new ParameterFields();
            ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
            paramField.Name = "?inst_id";

            paramDiscreteValue.Value = TextBoxINST_ID.Text;
            paramField.CurrentValues.Add(paramDiscreteValue);
            paramFields.Add(paramField);
            CrystalReportViewer1.ParameterFieldInfo = paramFields;

            CrystalReport.Load(Server.MapPath("~/Reports/ReportA.rpt"));
            CrystalReport.SetDatabaseLogon("Admin", "master22", @"SQL", "HOT");
            CrystalReport.Refresh();
            CrystalReportViewer1.ReportSource = CrystalReport;
        }
    }
}

推荐答案

我发现了我所遗漏的内容。这是我的更新代码。(突出显示更改



I found out what I was missing. Here is my updated code.(Changes highlighted)

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using CrystalDecisions.Web;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Windows.Forms;
using CrystalDecisions.ReportSource;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Xml.Linq;
using System.Web.SessionState;


namespace SACSCOCLogin1._1
{
    public partial class ReportFormA : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            TextBoxINST_ID.Text = Session["inst_id"].ToString();
            CrystalReportViewer1.Visible = true;

            ReportDocument CrystalReport = new ReportDocument();
            ParameterField paramField = new ParameterField();
            ParameterFields paramFields = new ParameterFields();
            ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();

            paramField.Name = "inst_id";
            paramField.CurrentValues.Clear();
            paramDiscreteValue = new ParameterDiscreteValue();
            paramDiscreteValue.Value = TextBoxINST_ID.Text;
            paramFields.Add(paramField);
            CrystalReportViewer1.ParameterFieldInfo = paramFields;

            CrystalReport.Load(Server.MapPath("~/Reports/FormAReport.rpt"));
            string sessiontype = TextBoxINST_ID.Text;
            CrystalReport.SetParameterValue("inst_id", TextBoxINST_ID.Text);

            string sessionid = TextBoxINST_ID.Text;
            <span class='highlight'>CrystalReport.SetParameterValue("inst_id", TextBoxINST_ID.Text)</span>;
            //CrystalReport.Refresh();
            CrystalReport.SetDatabaseLogon("Admin", "master22", @"SQL", "Hot");
            CrystalReportViewer1.ReportSource = CrystalReport;
        }
    }
}


这篇关于在Crystal Report中输入值时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆