刚刚开博,写一篇刚刚解决的一个问题吧!
在一道面试题上遇到了一个问题。
如何判断一个DataTable中的某列数据是否唯一
解决方法如下
1
DataTable dt
=
…;
2 DataView dv = new DataView(dt);
3 if(dv.Count != dv.ToTable( true ,"字段名").Rows.Count)
4 Response.Write("里面有不重复的数据");
2 DataView dv = new DataView(dt);
3 if(dv.Count != dv.ToTable( true ,"字段名").Rows.Count)
4 Response.Write("里面有不重复的数据");
感觉DataView 的功能还是挺强大的!