数据表 Select() 方法 [英] Datatable Select() Method
本文介绍了数据表 Select() 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 Datagridview,Data Source
是 dtCustomer
我只想根据搜索文本过滤网格视图的内容.尝试了以下代码
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 following code
DataTable dtSearch = dtCustomer;
dtSearch.Select("cust_Name like '" + txtSearch.Text + "%'");
grvCustomer.DataSource = dtSearch;
但这行不通.如果有人知道解决方案,请分享.
But this is not working. If any body knows the solution please share.
推荐答案
试试这个:
dtSearch.DefaultView.RowFilter = "cust_Name like '" + txtSearch.Text + "%'";
并通过修剪文本检查要删除的任何空间.
And check whatever there is space to be removed by triming the text.
这篇关于数据表 Select() 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文