I want to choose columns from a query with using the checkbox and Display in datagrid . In the following figure is an overview of the program :
and with this code for search :
Database1Entities DBE = new Database1Entities();
var search = from c in DBE.Tbl_PersonalInformation
where
string.IsNullOrEmpty(textBoxFirstName.Text) || (textBoxFirstName.Text) == (c.First_Name)
&&
string.IsNullOrEmpty(textBoxLastName.Text) || (textBoxLastName.Text) == (c.Last_Name)
select new { c.First_Name, c.Last_Name };
dataGrid.ItemsSource = search.ToList();
I would, for example if checkBoxFirstName.IsChecked==true
and checkBoxLastName.IsChecked==false
only FirstName
be displayed on the datagrid .