查找数据表中的值 [英] Find a value in DataTable

查看:103
本文介绍了查找数据表中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法找到的DataTable C#中的值,而不做行由行操作?

Is there a way to find a value in DataTable in C# without doing row-by-row operation?

的值可以是(的子串的一部分行[COLUMNNAME]。价值,通过逗号隔开)中的数据表中的单元和值可以存在于该行中的列中的任何一个。

The value can be a part of (a substring of row[columnName].value , separated by comma) a cell in the datatable and the value may be present in any one of columns in the row.

推荐答案

的DataTable或DataSet对象将有一个选择方法,将返回根据作为传递查询结果的一个DataRow数组它的参数。

A DataTable or DataSet object will have a Select Method that will return a DataRow array of results based on the query passed in as it's parameter.

看着你要求你的filterexpression将不得不略显一般,使这项工作。

Looking at your requirement your filterexpression will have to be somewhat general to make this work.

myDataTable.Select("columnName1 like '%" + value + "%'");

这篇关于查找数据表中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆