private void SearchButton_Click(object sender, RoutedEventArgs e)
{
EmployeeDataDataContext con = new EmployeeDataDataContext();
List<Employee> employees = (from s in con.Employees
where s.Name.ToLower() == SearchBox.Text.ToLower()
select s).ToList();
EmployeeGrid.ItemsSource = employees;
}
private void Edit_Click(object sender, RoutedEventArgs e)
{
Employee selected = EmployeeGrid.SelectedItem as Employee;
if (selected == null)
MessageBox.Show("You must select the employee.");
else
{
EditEmployee employee = new EditEmployee(selected);
employee.ShowDialog();
}
}
我按下搜索按钮时,无法获取列表中的任何内容。
答案 0 :(得分:0)
听起来你想要进行部分匹配。您可以where s.Name.ToLower().Contains(SearchBox.Text.ToLower())
使用
[
这将允许您的文本匹配名称列中的任何位置。