Datatable Select() Method

前端 未结 8 1653
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-11 16:15

I have a Datagridview and the Data Source is dtCustomer I just want to filter the content of grid view based on a search text. Itried the follow

8条回答
  •  孤城傲影
    2020-12-11 16:30

    I think this is what you're looking for?

    //DataTable dtSearch =  dtCustomer;
    //dtSearch.Select("cust_Name like '" + txtSearch.Text + "%'");
    
    
    grvCustomer.DataSource = dtCustomer.Select("cust_Name like '" + txtSearch.Text + "%'");
    

    And when you want to go back to the original data

    grvCustomer.DataSource = dtCustomer;
    

提交回复
热议问题