how to perform a search in dgview by date range

0

As I can perform a mediating search a date range with two datetimepicker and a button it is worth noting that I filled my datagridview in this way:

    adapter = new MySqlDataAdapter("Mostrar_ClientesExamen", C.conect);
    adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
    table = new DataTable();
    adapter.Fill(table);
    gridControl1.DataSource = table;
    C.CerrarConexion();
    
asked by Greyner Caceres Blandon 12.02.2017 в 06:26
source

1 answer

1

You could help with linq to perform the search within the grid

var result = from row in gridControl1.Rows.Cast<DataGridViewRow>()    
                where Convert.ToDateTime(row.Cells["nombrecolfecha"].Value) > dtpFechaDesde.Value
                   && Convert.ToDateTime(row.Cells["nombrecolfecha"].Value) > dtpFechaHasta.Value
            select row;

with this linq you get a list of rows that meet the condition, then you can go through them or maybe in the linq define a select and get a class, this will depend on what you want to do with the data obtained

    
answered by 13.02.2017 / 12:40
source