请求需要Crystal Report中的更多信息

时间:2016-08-12 05:22:38

标签: c# asp.net crystal-reports-2013

首先是那种形式的webform在点击按钮时有按钮然后想要报告另一个表格我创建这个

网络表单

 protected void Report_Click(object sender, EventArgs e)
    {
        report_class r = new report_class();
        data crystalReport = new data();
        r.BindReport(crystalReport,Convert.ToDateTime(fromdate.Value), Convert.ToDateTime(todate.Value), regiondrop.SelectedValue);
        Response.Redirect("Reports.aspx");


    }

然后我创建另一个类report_class

  public void BindReport(data crystalReport, DateTime fromdate, DateTime todate, string region)
    {
        T1 t = new T1();
        List<griddataresult_Result> dsc = t.griddataresult(fromdate, todate, region).ToList();
        DataTable dt = new DataTable();
        dt.Columns.Add("ID", typeof(int));
        dt.Columns.Add("Owner", typeof(string));
        foreach (var c in dsc)
        {

            dt.Rows.Add(c.ID, c.Owner);
        }

        crystalReport.DataDefinition.FormulaFields["region"].Text = "'" + region + "'";
        crystalReport.DataDefinition.FormulaFields["fromdate"].Text = "'" + fromdate + "'";
        crystalReport.DataDefinition.FormulaFields["todate"].Text = "'" + todate + "'";
        crystalReport.SetDataSource(dt);

    }

然后我报告.aspx我拖动了crystalreportviewer,我发现了这段代码

 protected void Page_Load(object sender, EventArgs e)
        {
            report_class r = new report_class();
            data crystalReport = new data();
         ConnectionInfo crConnectionInfo = new ConnectionInfo();
        crConnectionInfo.ServerName = "xxxx";
        crConnectionInfo.DatabaseName = "xxx";
        crConnectionInfo.UserID = "xxx";
        crConnectionInfo.Password = "xxx";
        crystalReport.Load(Server.MapPath("data.rpt"));
            CrystalReportViewer1.ReportSource = crystalReport;
            CrystalReportViewer1.DataBind();
        }

<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True"  Height="1202px" ReportSourceID="CrystalReportSource1" ToolPanelWidth="200px" Width="1104px" ToolPanelView="None" />

        <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
            <Report FileName="data.rpt">
            </Report>
        </CR:CrystalReportSource>

所以当我点击按钮然后点击Reports.aspx页面时会弹出一个字段 服务器名称,数据库名称,用户名,密码 所以默认情况下,DataSet1已经写入servername字段,databasename字段被禁用,然后我在最后2个字段中写入正确的用户名和密码,当我点击Enter然后再次弹出出现

所以我不需要这个弹出窗口以及如何解决这个问题?

0 个答案:

没有答案