【问题标题】:devexpress xtrareport binding multiple list datasourcedevexpress xtrareport 绑定多个列表数据源
【发布时间】:2013-04-21 05:42:15
【问题描述】:

我将类详细信息作为我的数据源附加到报告中;

class Detail
{ 
public string Name { get; set; }
public string State { get; set; }
public string City { get; set;}
public List<Transaction> tran { get; set; }
}
class Transaction
{
public string TransactionDate { get; set; }
public string TransactionDescription { get; set; } 
}

在我的查询中,我将其作为列表发送。

public List GetAccount(string account) {
List detail = new List();
sql ....
foreach (DataRow dr in dt.Rows)
{
detail.Add(new Detail()
{
  Name= dr["name"].Equals(DBNull.Value) ? string.Empty : dr["name"].ToString(),
 .....
  tran = GetTransactionDetail(account)// calling a list

 }); 
}
return detail;
}

public List<Transaction> GetTransactionDetail(string account)
{
....
}

在 Form1.cs 中

XtraReport1 rep = new XtraReport1();
printControl1.PrintingSystem = rep.PrintingSystem;
var ls = query.GetAccount(accountNo);
rep.DataSource = ls;
rep.CreateDocument();

在报告中我应该得到一个交易细节列表,但我只得到第一行。 谢谢,

【问题讨论】:

    标签: c# winforms devexpress xtrareport


    【解决方案1】:

    这取决于您的报告是如何设计的。通常,您需要一个单独的波段 (DetailReport) 才能显示所有详细信息(如果您使用的是 XRTable)。

    【讨论】:

      【解决方案2】:

      先生,您应该使用DataSetquery.GetAccount(accountNo) 返回DataTable 然后像这样尝试。它对我有用。

      XtraReport1 rep = new XtraReport1();
      printControl1.PrintingSystem = rep.PrintingSystem;
      var ds = new ds("TestDataSet");
      var ls = query.GetAccount(accountNo);
      ds.Tables.Add(ls);
      rep.DataSource = ds;
      rep.DataMember = ls.TableName;
      rep.CreateDocument();
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-08-29
        • 1970-01-01
        • 1970-01-01
        • 2019-02-13
        • 2013-01-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多