public void GetFiltred(DataGrid dg, DataGrid dg2, int FirstData, int SecondData) { List <Deliver> FiltredDeliverList = new List <Deliver>(); List <Deliver> deliverList = sc.GetDeliver().ToList(); dg2.DataContext = deliverList; foreach (var item in deliverList) { if (int.Parse(item.OrderDate) >= FirstData && int.Parse(item.OrderDate) <= SecondData) { FiltredDeliverList.Add(item); } } dg.DataContext = FiltredDeliverList; }