我有一个这样构造的转发器“语句”:
<asp:Repeater ID="Statements" runat="server"><ItemTemplate><ul>
<li>
<div>
<asp:Label Text='<%#("Problem Statement: " + Eval("Statement"))%>' runat="server"></asp:Label></div>
<div>
<asp:Label Text='<%#("Goal: " + Eval("Goal"))%>' runat="server"></asp:Label></div>
<asp:CheckBoxList ID="Objectives" runat="server" RepeatDirection="Horizontal" RepeatColumns="2">
</asp:CheckBoxList>
</li>
</ul>
</ItemTemplate>
</asp:Repeater>
我试图从重复的 中提取所有已检查的项目CheckBoxList
,但到目前为止,还没有运气。下面给了我一个无效的转换错误,但我的其他尝试也导致了失败。如何使用 LINQ 从重复列表中提取所有选中的项目?
Dim list = _
(From c As Control In Me.FindControl("Statements").Controls _
Where c.GetType() Is GetType(CheckBoxList) _
Select c).ToList()
Dim selected = _
From c As CheckBoxList In list.AsEnumerable() _
Select c.Items.AsQueryable().Cast(Of ListItem).Select(Function(l) l.Selected = True)
提前致谢。