如何在 VS Report Viewer 2010 中显示子列表项
我想做的是使用还包含子列表的数据源创建一个报告。
因此,一个简单的示例如下,其中项目列表是我的数据源,我还想显示任务列表。
public class Item
{
public string itemName;
public List<Task> tasks;
}
public class Task
{
public string taskName;
}
问题是,当我添加数据源时,itemName 显示为字段,但我看不到任务。
我发现了这个问题: How to display a child List inside of the DataSource in VS Report Viewer 2008? 这看起来很相似,但我无法理解答案。我对这些报告还很陌生,因此我们将不胜感激。
谢谢, 马特
What I'm trying to do is to create a report using a datasource that also contains a child list.
So, an simple example is as follows, where a List of Items is my datasource and I want to also display the list of tasks.
public class Item
{
public string itemName;
public List<Task> tasks;
}
public class Task
{
public string taskName;
}
The problem is that when I add the datasource, itemName shows up as a field but I can't see the tasks.
I found this question: How to display a child List inside of the DataSource in VS Report Viewer 2008? which seems similar, but I couldn't understand the answer. I'm pretty new at these reports so any help would be appreciated.
Thanks,
Matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定这是否是您想要的,但您可能会考虑将 Item 类展平为数组或字符串列表,并将它们绑定到目标控件。
您可以使用以下 LINQ 代码来获取扁平化的字符串列表:
PS:公共变量通常不使用驼峰式大小写,而是使用 Pascal 大小写。
Not sure if that is what you want, but you might consider flattening your Item class into an array or list of strings and bind those to your target control.
You can use the following LINQ code to get a flattened list of strings:
P.S.: It is usual not to use camel casing, but rather Pascal casing for public variables.