private void Search(object sender, EventArgs e) { if (((MainForm)this.MdiParent).ActiveMdiChild == this) { dgvLinelist.EndEdit(); string fname = txtLineName.Text.Trim(); LineVO vo = new LineVO() { corporation_id = cboCorporationName.SelectedValue.ToInt(), factory_id = cboFactoryName.SelectedValue.ToInt() }; dtDgv = service.LineSearch(vo); DataView dv = dtDgv.DefaultView; if (fname.Length > 0) { dv.RowFilter = $"line_name like '%{fname}%'"; } dgvLinelist.DataSource = dv; DataTable dt = dv.ToTable(); List <LineVO> sortedData = SqlHelper.ConvertDataTableToList <LineVO>(dt); dgvLinelist.DataSource = sortedData; } }