1

我试图从我的类对象中显示一个 rdlc 报告

这是课程

public class BillInfo
{
    public String Name { get; set; }
    public String Date { get; set; }
    public String splInstructions { get; set; }
    public List<OrderItem> oItems { get; set; }
    public String GrossTotal { get; set; }
    public String DiscountAmount { get; set; }
    public String NetTotal { get; set; }
}

public class OrderItem
{
    public OrderItem() { }
    public OrderItem(String sNo, String Qty, String Amt, String ttl) 
    {
        this.SNo = sNo;
        this.Quantity = Qty;
        this.Amount = Amt;
        this.Total = ttl;
    }

    public String SNo { get; set; }
    public String Quantity { get; set; }
    public String Amount { get; set; }
    public String Total { get; set; }
}

现在我在数据源窗口中添加类BillInfo的数据源对象并添加了一个报表查看器,现在当我尝试将数据源值添加为账单信息类的对象时,它给了我这个奇怪的错误

this.BillDataViewer.LocalReport.ReportPath = "C:/Users/Guest1/Desktop/Billinator/Billinator/MainReport.rdlc";
this.BillDataViewer.LocalReport.DataSources.Add(new ReportDataSource("BillInfo", MainForm.GetBillData()));
this.BillDataViewer.RefreshReport();

我添加数据源的第二行给了我这个错误

Value does not fall within the expected range.

" 在 Microsoft.Reporting.WinForms.ReportDataSource.set_Value(Object value)\r\n 在 Billinator.ReportViewer.ReportViewer_Load(Object sender, EventArgs e) 在 C:\Users\Guest1\Desktop\Billinator\Billinator\ReportViewer.cs:第 23 行\r\n 在 System.Windows.Forms.Form.OnLoad(EventArgs e)\r\n 在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)\r\n 在 System.Windows.Forms.Control .CreateControl()\r\n 在 System.Windows.Forms.Control.WmShowWindow(Message& m)\r\n 在 System.Windows.Forms.Control.WndProc(Message& m)\r\n 在 System.Windows.Forms .Control.ControlNativeWindow.WndProc(Message& m)\r\n at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)"

请建议我哪里出错了

4

0 回答 0