2015-11-10 34 views
1

我有一個對象具有關於訂單的標題級別詳細信息以及訂單詳細信息列表。Winforms報表(RDLC)在運行時與具有列表屬性的對象綁定

頭信息填充很好,但我無法弄清楚如何將訂單詳細信息列表綁定到我在報表上的Tablix。

這是錯誤的方法? 數據連接正在運行時確定,所以我不認爲我可以輕鬆地將子報表掛接到數據庫並通過過濾器。

編輯:我應該補充說我有一個ReportViewer的父窗體,如果它有所作爲。這就是我設置數據源的地方。

public class FormulaHeaderModel 
{ 
    public string flavor { get; set; } 
    public string name { get; set; } 
    public string author { get; set; } 
    public string formulaId { get; set; } 
    public string formulaNumber { get; set; } 
    public string formulaType { get; set; } 
    public string accessLevel { get; set; } 
    public string createdOnDate { get; set; } 
    public string formulaWeight { get; set; } 
    public string note { get; set; } 
    public List<FormulaDetailModel> dataCharacterizing { get; set; } 
    public List<FormulaDetailModel> dataContributory { get; set; } 
    public List<FormulaDetailModel> dataGlobal { get; set; } 
    public List<FormulaDetailModel> dataCarrier { get; set; } 
} 
    public class FormulaDetailModel 
{ 
    public int formulaID { get; set; } 
    public int ingredientTypeId { get; set; } 
    public string codeFema { get; set; } 
    public decimal ingredientCost { get; set; } 
    public string name { get; set; } 
    public string natural { get; set; } 
    public decimal ppm { get; set; } 
    public decimal percentSolution { get; set; } 
    public decimal grams {get; set;} 
} 

我需要爲每個列表都有一個tablix。

因此,頂部是字符串級別的信息,然後是4個FormulaDetailModel列表中的每一個的標籤和Tablix(或其他)。

+0

這聽起來應該是可行的 - 你可以分享你試圖報告的數據結構嗎?並且所需的輸出(即使是設計的油漆模型也會有所幫助) – Jonnus

+0

只需編輯以包含數據結構。 – user3918989

回答

0

明白了。只要名稱與表格設置的數據集名稱相匹配,我就可以添加第二個數據源。

this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FormulaDetailModel", fhModel.dataCharacterizing)); 
相關問題