报表查看器无法在Visual Studio中工作

时间:2017-06-11 14:59:18

标签: c# reporting reportviewer

我使用c#的报表查看器有问题。我创建了一个报告并将报告查看器添加到我的表单中,并使用代码将报告添加到报告查看器,但它不起作用并显示消息

  

尚未指定报告定义的来源

这是我的代码:

public partial class ShowReportsForm : Form
{
    string STUTS, ID;

    DataSetForAllProducts datasetforallprodect = new DataSetForAllProducts();
    DataSetForAllProducts datasetforsingleproduct = new DataSetForAllProducts();

    ReportDataSource ReportDataSorce1 = new ReportDataSource();
    BindingSource BS = new BindingSource();

    public ShowReportsForm(string stuts)
    {
        InitializeComponent();
        STUTS = stuts;
    }

    public ShowReportsForm(string stuts, string id)
    {
        InitializeComponent();
        STUTS = stuts;
        ID = id;
    }

    private void ShowReportsForm_Load(object sender, EventArgs e)
    {
        if (STUTS == "getallproducts")
        {
            this.reportViewer1.LocalReport.ReportEmbeddedResource = 
            "Prodects_Management.RPT.ReportAllProducts.rdlc";
            BS.DataMember = "PRODECTS";
            ReportDataSorce1.Value = BS;
            BS.DataSource = datasetforallprodect;
            DataSetForAllProductsTableAdapters.PRODECTSTableAdapter cstp = 
            new DataSetForAllProductsTableAdapters.PRODECTSTableAdapter();
            cstp.Fill(datasetforallprodect.PRODECTS);
            ReportDataSorce1.Name = "DataSetForAllProducts";

            this.reportViewer1.LocalReport.DataSources.Add(ReportDataSorce1);
        }
        else if(STUTS == "getsingleproduct")
        {
        }

        this.reportViewer1.RefreshReport();
     }
  }

0 个答案:

没有答案