private void SearchStudent( ) { if(readAll != null) { var query = from item in readAll where item.name == SearchBox.Text select item; if (query.Any()) { writeOne.Clear(); oneGridModel.Clear(); foreach (var item in query) { GridModel gm = new GridModel() { name = item.name ,hms = item.hms ,termId = item.termId ,roomNum = item.roomNum ,ymd = item.ymd}; //item.ymd.ToShortDateString() WriteItem wi = new WriteItem() { ymd = item.ymd, hms = item.hms , name = item.name, roomNum = item.roomNum, termId = item.termId }; writeOne.Add(wi); oneGridModel.Add(gm); } IsSearch = true; DG1.Items.SortDescriptions.Clear(); DG1.Items.SortDescriptions.Add(new SortDescription("roomNum", ListSortDirection.Ascending)); } } }