DataGrid I fill like this:
String strConnection = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(strConnection);
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter("Select * from RNames", con);
SqlCommandBuilder cmd = new SqlCommandBuilder(da);
da.Fill(dt);
dataGrid1.ItemsSource = dt.DefaultView;
Filtering in the DataGrid is as follows:
private void checkBox1_Checked(object sender, RoutedEventArgs e)
{
((DataView)dataGrid1.ItemsSource).RowFilter = "fname = 'fname1'";
}
private void checkBox2_Checked(object sender, RoutedEventArgs e)
{
((DataView)dataGrid1.ItemsSource).RowFilter = "fname = 'fname2'";
}
And how to do that when you click on checkBox1 and checkBox2, are displayed in the
fname1 lname1
fname2 lname2