Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 比较通过LINQ未检查的复选框列表值_C#_Linq - Fatal编程技术网

C# 比较通过LINQ未检查的复选框列表值

C# 比较通过LINQ未检查的复选框列表值,c#,linq,C#,Linq,我使用下面的代码在复选框列表的基础上进行过滤,但是,如果我没有选择任何内容,过滤器将不起作用。如果我没有检查任何值,它必须显示所有值 以下是代码: var selectedIds = chklstDepartment.Items.Cast<ListItem>().Where(item => item.Selected).Select(item => item.Value).ToArray(); List<LessonL

我使用下面的代码在复选框列表的基础上进行过滤,但是,如果我没有选择任何内容,过滤器将不起作用。如果我没有检查任何值,它必须显示所有值

以下是代码:

var selectedIds = chklstDepartment.Items.Cast<ListItem>().Where(item => item.Selected).Select(item => item.Value).ToArray();
                        List<LessonLearnDetails> objLessonDetails = objLessonDashboard.getLessonLearntDetails();
                        var searchData = objLessonDetails.Where(i => (ddlAsset.SelectedValue == "0") || (i._Asset.AssetID == ddlAsset.SelectedValue))
                    .Where(i => (ddlAuditType.SelectedValue == "0") || (i._Audit.AuditTypeID == ddlAuditType.SelectedValue))
                    .Where(i => (chklstDepartment.SelectedValue == "0") || (selectedIds.Contains(i._Department.DepartmentID)))
                    .Where(i => (ddlCategory.SelectedValue == "0") || (i._Category.CategoryID == ddlCategory.SelectedValue))
                      .Where(i => (ddlStartYear.SelectedItem.Text == "--Select All--") || (Convert.ToInt32(i._Year.StartYear) >= Convert.ToInt32(ddlStartYear.SelectedItem.Text)))
                .Where(i => (ddlEndYear.SelectedItem.Text == "--Select All--") || (Convert.ToInt32(i._Year.EndYear) <= Convert.ToInt32(ddlEndYear.SelectedItem.Text)))
                    .Distinct().ToList();
                        BindGrid(searchData);
var selectedds=chklstDepartment.Items.Cast().Where(item=>item.Selected).Select(item=>item.Value).ToArray();
List objlessondails=objlessondashoard.getLessonLearntDetails();
var searchData=objLessonDetails.Where(i=>(ddlaste.SelectedValue==“0”)| |(i._Asset.AssetID==ddlaste.SelectedValue))
。其中(i=>(ddlAuditType.SelectedValue==“0”)| |(i._Audit.AuditTypeID==ddlAuditType.SelectedValue))
其中(i=>(chklstDepartment.SelectedValue==“0”)| |(selectedDS.Contains(i.(u Department.DepartmentID)))
。其中(i=>(ddlcography.SelectedValue==“0”)| |(i._Category.CategoryID==ddlcography.SelectedValue))
.Where(i=>(ddlStartYear.SelectedItem.Text==“--Select All-->”)| |(Convert.ToInt32(i.。_Year.StartYear)>=Convert.ToInt32(ddlStartYear.SelectedItem.Text)))
。其中(i=>(ddlEndYear.SelectedItem.Text==“--Select All——”)| |(Convert.ToInt32(i.(u Year.EndYear)使用“”代替“0”


如果您没有检查任何值,当前结果是什么?计数即将为0不检查时,您确定
SelectedValues
是“0”还是--selected All--“?您如何证明?它即将到来”,我已经检查过了。我没有想到它,而是做了很多更改。谢谢…如果值不是“0”或--selected All--”,您应该更改代码。
chklstDepartment.SelectedValue == ""