首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

水晶报表绑定强类型dataset数据源,报表显示一片空白,该如何解决

2013-10-21 
水晶报表绑定强类型dataset数据源,报表显示一片空白绑定代码 private void Form1_Load(object sender, Eve

水晶报表绑定强类型dataset数据源,报表显示一片空白
绑定代码

 
private void Form1_Load(object sender, EventArgs e)
        {
            DataSet1.WisTable3DataTable dt = new DataSet1.WisTable3DataTable();
            new WisTable3TableAdapter().全镇出生查询(dt);
            chushengyuebao yb = new chushengyuebao();
            yb.SetDataSource((System.Data.DataTable)dt);
            
        }


[解决办法]
参考:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using System.Data;
using Glacier.BOS.EDM;
using Glacier.BOS.BUL;
using GlacierV2.Common.Data;
using GlacierV2.Extensions;
using Glacier.BOS.WebClient.Common;

namespace Glacier.BOS.WebClient.Pages.Report
{
    public partial class PrintReceipt : System.Web.UI.Page
    {
        ReportDocument rptDocument = new ReportDocument();
        protected void Page_Load(object sender, EventArgs e)
        {
            PrintOrderPayment userReport = new PrintOrderPayment();
            string ReportType = Request["ReportType"].ToString();
            int OrderPaymentID = int.Parse(Request["OrderPaymentID"].ToString());
            int OrderTypeID = GetOrderTypeID(ReportType);
            List<OrderPayment> list = ReportSRV.GetOrderPaymentReportData(OrderTypeID, OrderPaymentID);
            var list2 = list.Select(t =>
            {
                return new
                {
                    t.OrderTypeID,
                    t.OrderNo,
                    t.OrderDate,
                    t.ShortCode,
                };
            }).ToList();
            userReport.SetDataSource(list2);
            rptView.ReportSource = userReport;


        }


    }
}


你要确保数据源有数据
[解决办法]

ReportDocument rDoc1 = new ReportDocument();
            //DataGridview中的datatable复制到指定的指定DataTable中,为水晶报表提供
            SPDataSet ds1 = new SPDataSet();
            DataTable tabl = ((spList)_parentForm).GetDgvToTable();
            foreach (DataRow dr in tabl.Rows)
            {
                ds1.SPTable.ImportRow(dr);
            }
            //绑定水晶报表
            CrystalReport1 cry = new CrystalReport1();


            cry.Refresh();
            cry.SetDataSource(ds1.Tables["SPTable"]);
            this.crystalReportViewer1.ReportSource = null;
            this.crystalReportViewer1.ReportSource = cry;
            this.crystalReportViewer1.RefreshReport();

热点排行