【发布时间】:2014-08-19 13:27:38
【问题描述】:
我浏览了一堆例子,我被这个问题困住了......
数据
CategoryId OptionId CategoryName OptionName
1 2 Type Black & White
1 3 Type Color
2 4 Print Speed Less than 21 ppm
2 5 Print Speed 21-30 ppm
2 6 Print Speed 31-45 ppm
2 7 Print Speed 46-55 ppm
2 8 Print Speed 56-70 ppm
2 10 Print Speed 71 plus ppm
3 11 Software 3.5
3 12 Software 4
4 13 User Interface 7" Touch-Screen
4 14 User Interface 8.5" Touch-Screen
4 15 User Interface 10.1" Touch-Screen
4 16 User Interface 15.4" Touch-Screen
我希望父转发器在 CategoryName 上做不同的事情,但是当我这样做时,我没有在我的嵌套转发器中获得所有 OptionNames。我正在使用数据表来填充父中继器。我已经尝试过 linq 和 distinct 可以正确显示类别名称和选项,但我需要嵌套中继器中的 ID...
我正在使用这个示例 - Databind repeater using Linq with group by 如何更改 linq 以包含更多字段,我对 Linq 不是很熟悉。
Parent Repeater Databind
Repeater1.DataSource = (from x in csvData.AsEnumerable() select x["category"]).Distinct();
Nested Repeater Databind
rptr.DataSource = csvData.AsEnumerable().Where(x => x["category"].Equals(e.Item.DataItem));
【问题讨论】: