写了一个类,想要让ReportViewer实现报表功能。代码如下:
class Class1
{
public class Classification
{
private string ClassificationName;
private string ProductName;
private int ProductPrice;
public Classification(string str1, string str2, int PP)
{
ClassificationName = str1;
ProductName = str2;
ProductPrice = PP;
}
public string C_name
{
get { return ClassificationName; }
}
public string P_name
{
get { return ProductName; }
}
public int P_price
{
get { return ProductPrice; }
}
}
public class SentToReporter
{
private List<Classification> TheList;
public SentToReporter()
{
TheList = new List<Classification>();
TheList.Add(new Classification("Apple", "RedApple", 10));
TheList.Add(new Classification("Apple", "YellowApple", 12));
}
public List<Classification> GetTheList()
{
return TheList;
}
}
}
之后,进行了“生成”操作,然后添加“报表向导”。
但奇怪的是在“选择数据对象”窗口中,当我把报表绑定数据源指定为Classification然后点击“完成”键时,
系统出现了提示:未将对象引用设置到对象实例!
这是怎么回事啊?有大虾来指导一下吗?谢谢