添加两个TEXT字段然后在绑定报表时候传送过去

解决方案 »

  1.   

    string TEXT_OBJECT_NAME = @"Text15";
    TextObject text;
    text = cr.ReportDefinition.ReportObjects[TEXT_OBJECT_NAME] as TextObject;
    text.Text = "测试"; string TEXT_OBJECT_NAME2 = @"Textbgdate";
    TextObject text2;
    text2 = cr.ReportDefinition.ReportObjects[TEXT_OBJECT_NAME2] as TextObject;
    text2.Text = "测试2";
      

  2.   

    在报表界面上拖个文本框!
    string time="日期控件的时间值";
    CrystalDecisions.CrystalReports.Engine.TextObject t = (CrystalDecisions.CrystalReports.Engine.TextObject)cr.ReportDefinition.ReportObjects["TXT1"]; 
    t.value=time;
      

  3.   

    水晶报表传参数的方法:        ' 隐藏Report Viewer中MAIN REPORT的状态栏
            For i As Integer = 0 To Me.CrystalRPT.Controls.Count - 1
                Console.WriteLine(Me.CrystalRPT.Controls(i).GetType.ToString)
                If TypeOf (Me.CrystalRPT.Controls(i)) Is System.Windows.Forms.StatusBar Then
                    Me.CrystalRPT.Controls(i).Visible = False
                End If
            Next
    因为我的打印窗体只有两个共用的,一个单表打印,一个主从表打印,
    所以参数传入时我会考虑通过SQL的存储过程中传入,作为一个字段在报表上显示.
      

  4.   

    ...发错.        ' 在报表中显示列印者名字
            Try
                Dim GetTextObject As TextObject
                ' 按名称获取 ReportObject,将其转换为 TextObject,并返回此对象。
                  GetTextObject = Rpt_Document_m.ReportDefinition.ReportObjects.Item("TXT_USER_DESC")
                GetTextObject.Text = STR_USER_DESC_G.Trim
            Catch ex As Exception
            End Try
      

  5.   

    给你一个完整的代码  string connStr = ConfigurationManager.ConnectionStrings["cnpsConn"].ToString();
      string starrq=textbox1.text;
      string endrq=textbox2.text;
            SqlDataSource datasource = new SqlDataSource(connStr, "SELECT * from cldd WHERE (ywrq >='"+starrq+"' ) AND (b.yhrq <='"+endrq+"')");
            ReportDocument doc = new ReportDocument();        TableLogOnInfo logininfo = new TableLogOnInfo();
            string path;        path = Server.MapPath("CrystalReport4.rpt");
            doc.Load(path);
            string a, b, c, d;
            a = System.Configuration.ConfigurationManager.AppSettings[0];
            b = System.Configuration.ConfigurationManager.AppSettings[1];
            c = System.Configuration.ConfigurationManager.AppSettings[2];
            d = System.Configuration.ConfigurationManager.AppSettings[3];
            logininfo.ConnectionInfo.ServerName = a;
            logininfo.ConnectionInfo.DatabaseName = b;
            logininfo.ConnectionInfo.UserID = c;
            logininfo.ConnectionInfo.Password = d;
            GridView1.DataSource = datasource;
            GridView1.DataBind();        try
            {
                doc.Database.Tables[0].ApplyLogOnInfo(logininfo);
                doc.Database.Tables[0].SetDataSource(datasource.Select(DataSourceSelectArguments.Empty));
                CrystalReportViewer1.ReportSource = doc;
            }
            catch
            {
                Response.Write("<script>alert('输出报表失败,请检查输入信息或网络!');</script>");
            }