【问题标题】:"a data source instance has not been created for dataset" no databindings and datasources found C#“尚未为数据集创建数据源实例”未找到数据绑定和数据源 C#
【发布时间】:2014-01-16 18:17:35
【问题描述】:

我使用 Visual Studio 报表向导创建了一个报表,并将业务对象用作数据源。我首先创建了我的类并向其中添加了对象。然后我使用报告向导创建报告。一切正常,直到我添加新的对象/类。数据源开始消失。我知道在创建报表查看器之后,我们应该使用智能标记(小三角形)甚至“选择数据源”来绑定数据源,以将其与已经令人兴奋的数据源绑定。但是我的数据源窗格是空白的。这是我添加一个新类后的样子:

我查看了this thread,但是由于我使用对象而不是类型化数据集创建数据集,因此我没有发现它有帮助。我已经使用报告向导为我生成报告,因此我没有忘记编写任何数据源代码(希望如此)。下面是我的 Form.cs 的样子:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ReportsApplication2
{
    public partial class Form1 : Form
    {
        private Products m_products = new Products();
        private AlertsList m_alert = new AlertsList();
        private ActionsList m_actionsl = new ActionsList();
        private GradeList m_gradesl = new GradeList();

        public Form1()
        {
            InitializeComponent();

        }


        private void Form1_Load(object sender, EventArgs e)
        {

           this.PaperBindingSource.DataSource = m_products.GetProducts();
           this.AlertBindingSource.DataSource = m_alert.GetAlertsList();
           this.ActionBindingSource.DataSource = m_actionsl.GetActionsList();
           this.bindingSource1.DataSource = m_gradesl.GetGradeList();
           this.reportViewer1.RefreshReport();

        }

        private void reportViewer1_Load(object sender, EventArgs e)
        {

        }

        private void ActionBindingSource_CurrentChanged(object sender, EventArgs e)
        {

        }

        private void reportViewer1_Load_1(object sender, EventArgs e)
        {

        }
    }
}

【问题讨论】:

    标签: c# visual-studio-2012 reporting


    【解决方案1】:

    将此作为有相同问题的人的答案:

    我学到的最痛苦的方法是永远不要使用报表向导来创建报表和数据集。必须在没有向导的情况下手动创建报表,并且必须在数据集设计器中绘制数据集。 Here is a my blog with detailed description

    【讨论】:

      猜你喜欢
      • 2011-04-30
      • 1970-01-01
      • 1970-01-01
      • 2011-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多