c# - 组合框不正确地过滤 datagridview 数据
问题描述
我面临一个导致过滤器工作不正常的错误 - 也就是说,当我更改组合框中的值时,datagridview 变为空
我使用的代码是:
dataGridView1.DataSource = db.GetInfo()
.Where(x => x.Title == cbxSorting.SelectedText)
.ToList();
解决方案
我不知道为什么,但有时属性“SelectedValue”和“SelectedText”不能正常工作,我建议你使用 SelectedItem
cbxSorting.SelectedItem?.ToString()
推荐阅读
- mysql - MySQL中的排序列
- javascript - 如何在按钮单击时添加输入字段
- sql - 根据特定的子字符串短语获取数值
- angular - 调用component.html的插值到component.ts
- javascript - MobX:如何改变一个可观察值以响应另一个值的变化?
- vba - 在 Excel 中没有下一个
- django - 有没有办法在 Django 模型的查询集中隐藏对象?
- php - 经过身份验证的网页(通过 php/html + .htaccess)看不到其他目录(css、JavaScript、图像等)中的资产
- c++ - C++:编译全局数组的时间
- javascript - 将 fadeOut() 限制为每秒 3 步