如果选择了一个或多个特定复选框列表项,我正在尝试找到正确的代码隐藏以显示列表框。复选框列表是从实体数据源创建的,并且该源的 SQL 表还有一个字段,指示该选择是否应显示列表框。哇!该表如下所示:
GUID grade_level show_college_list
(gen) 12 0 (bit)
(gen) College 1
asp是这样的:
<asp:EntityDataSource ID="GradeLevelEntityDataSource" runat="server"
ConnectionString="name=NewCourseRequestDataEntities"
DefaultContainerName="NewCourseRequestDataEntities" EnableFlattening="False"
EntitySetName="grade_levels" OrderBy="it.grade_level_description">
</asp:EntityDataSource>
<asp:Label ID="Label7" cssClass="leftlabel" runat="server" text="Grade Level (check all that apply):"></asp:Label>
<asp:CheckBoxList ID="GradeLevelCheckBoxList" runat="server" cssClass="horizontalcontrols"
DataSourceID="GradeLevelEntityDataSource"
DataTextField="grade_level_description" DataValueField="grade_level_id" AutoPostBack="True"
OnSelectedIndexChanged="CollegeInstitutionsListboxChange"
RepeatDirection="Horizontal" RepeatLayout="Flow">
</asp:CheckBoxList>
如果选中 College,我希望显示机构列表框面板。这是我对代码的了解:
if (sender != null)
{
foreach (ListItem grade in GradeLevelCheckBoxList.Items)
{
if (grade.Selected == true)
{
NewCourseRequestDataEntities context = new NewCourseRequestDataEntities();
var guids = from g in context.grade_levels where g.show_college_list == true select g;
if ( guids.Contains(new Guid(grade.Value)) )
{
testselected.Text = grade.Value; //for testing
CollegeInstitutionsSelectPanel.Visible = true;
}
}
}
}
我在 contains 方法上收到这两个错误。我不知道他们是什么意思。
错误 1 实例参数:无法从 'System.Linq.IQueryable' 转换为 'System.Linq.ParallelQuery' Y:\visual studio\New Course Request\NewCourseRequestForm.aspx.cs 146 34 New Course Request
错误 2 'System.Linq.IQueryable' 不包含 'Contains' 的定义,并且最佳扩展方法重载 'System.Linq.ParallelEnumerable.Contains(System.Linq.ParallelQuery, TSource)' 有一些无效参数 Y:\visual工作室\新课程请求\NewCourseRequestForm.aspx.cs 146 34 新课程请求
有人可以帮忙吗?