Linq IList<T> 隐藏数据并绑定到 gridview

Linq IList<T> hide data and bind to gridview

这是 window 表单,在 CardD 中包含一个项目列表,当复选框处于活动状态时检查我如何不显示该项目未激活?

private void BindCardRecord(IList<CardDto> cardDto)
{

   if (chkSearch_NonActive.Checked)
   {
      cardDto.Where(p => p.IsActive == false);
   }

    dgvSearchResult.DataSource = cardDto.ListToDataTable();
}

假设 "kick" 你的意思是 "not show"

private void BindCardRecord(IList<CardDto> cardDto)
{

   if (chkSearch_NonActive.Checked)
   {
      var newList = cardDto.Where(p => p.IsActive == false).ToList();
      dgvSearchResult.DataSource = newList.ListToDataTable();
   }
}