我怎样才能访问该组一个LINQ的组通过查询从嵌套Repeater控件? [英] How can I access the group of a linq group-by query from a nested repeater control?

查看:149
本文介绍了我怎样才能访问该组一个LINQ的组通过查询从嵌套Repeater控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用通过查询LINQ组(两编组参数),想用所得到的数据在嵌套中继器。

I'm using a linq group by query (with two grouping parameters) and would like to use the resulting data in a nested repeater.

var dateGroups = from row in data.AsEnumerable()
    group row by new { StartDate = row["StartDate"], EndDate = row["EndDate"] };

数据是从的SqlDataAdapter填充DataSet中的数据表。 dateGroups在父中继器使用,并且我可以访问使用eval(key.StartDate)和eval组键(key.EndDate)。

"data" is a DataTable from an SqlDataAdapter-filled DataSet. "dateGroups" is used in the parent repeater, and I can access the group keys using Eval("key.StartDate") and Eval("key.EndDate").

由于dateGroups实际上包含了开始/结束日期分组整齐的所有数据行,我想访问这些行一个孩子中继器显示的数据。

Since dateGroups actually contains all the data rows grouped neatly by Start/End date, I'd like to access those rows to display the data in a child repeater.

要什么我会设置中继子的DataSource?我试图在标记我能想到的每一个前pression;我认为问题是,我试图访问一个匿名成员(我不知道怎么办。)如果它没有变成是显而易见的,这将是前pression访问元素在孩子中继器的每次迭代?

To what would I set the child repeater's DataSource? I have tried every expression in markup I could think of; I think the problem is that I'm trying to access an anonymous member (and I don't know how.) In case it doesn't turn out to be obvious, what would be the expression to access the elements in each iteration of the child repeater?

有一个前pression,将让我设置标记的数据源,还是会必须在父中继某些事件?

Is there an expression that would let me set the DataSource in the markup, or will it have to be in the codebehind on some event in the parent repeater?

推荐答案

使用一个已知类类型,而不是一个匿名类。否则,你将不得不使用反射来检查匿名类型它得到丑陋。

Use a know class type rather than an anonymous class. Otherwise you will have to use reflection to inspect the anonymous type which gets ugly.

这篇关于我怎样才能访问该组一个LINQ的组通过查询从嵌套Repeater控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆