我如何使用DataView RowFilter语法[C#] [英] How can i use DataView RowFilter Syntax [C#]

查看:84
本文介绍了我如何使用DataView RowFilter语法[C#]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 System.Data.DataTable db = GetExcelData(path,oSheet.Name); 
foreach (DataColumn item in db.Columns)
{
string 值= db.Rows [ 0 ] [ ]。ToString();
columnNames.Add(item.ColumnName);
}



i有问题当我在datatable中使用过滤行时列名包含额外的值,如(_x0020_)如何避免这个问题,即使列包含一个单词没有空间...

当我检查xml中的结果时,它显示年份< year_x0020_> 1427< year_x0020_>



所以如何在Year列中找到这个值



最好的关注

解决方案

  dataView  RowFilter   =  empid   =  8; 

其他 示例
dataView RowFilter = EmpName = 'Pankaj';
dataView RowFilter = 日期 = #12/08/2000# ;

比较
dataView RowFilter = Date> =<跨越式s =code-leadattribute> + + startdate +
并且 日期< = + + enddate + #;
find < span class =code-leadattribute>其他 示例 at:
< span class =code-leadattribute> http: // www.csharp-examples.net/dataview -rowfilter /


System.Data.DataTable db = GetExcelData(path, oSheet.Name);
                foreach (DataColumn item in db.Columns)
                {
                    string Value = db.Rows[0]["Year"].ToString();
                    columnNames.Add(item.ColumnName);
                }


i have problem when i use filter row in datatable the column name contain extra value like (_x0020_) how can avoid this problem even the columns contain one word and no space...
when I check the result in the xml its showing the year like <year_x0020_>1427<year_x0020_>

so how can I find this value in the Year column

Best regard

解决方案

dataView.RowFilter = "empid = 8";

Other examples are
dataView.RowFilter = "EmpName = 'Pankaj'" ;
dataView.RowFilter = "Date = #12/08/2000#" ;

Comparision
dataView.RowFilter = "Date>=" + "#" + startdate + "#" +
"And Date <=" + "#" + enddate + "#";
You can find other examples at:
http://www.csharp-examples.net/dataview-rowfilter/


这篇关于我如何使用DataView RowFilter语法[C#]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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