数据表过滤器Doest在数据集上无法正常工作。 [英] Data table filter Doestn't work properly on Dataset.

查看:62
本文介绍了数据表过滤器Doest在数据集上无法正常工作。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据集中有产品清单...我需要根据产品价格过滤产品......价格必须在最低和最高价格之内.....我试过这个

I have a Products list on table in my Dataset...i need to filter products depend on price of products... the price must be within minimum and maximum price .....i tried this

DataSet TempAdsDS=new DataSet();
TempAdsDS = (DataSet)Session["DS"];
rows = TempAdsDS.Tables[0].Select("Price > " + Minimum + " and Price < " + Maximum);





但它会过滤产品,但结果中也有一些错误的产品....如何过滤完全正确代码后面的产品...... plz给出了对表格中过滤精确结果的建议.....



But It will filter products but some wrong products are also available in result.... How can i filter exact correct products in code behind......plz give suggesion for filter exact results from table.....

推荐答案





首先检查价格列数据类型它应该是数字(Int,Decimal,Float,Double)否则它将不会显示正确的值。



除了保持session / ViewState中的数据集不是一个好主意,因此您可以在文件中写入数据集并将其存储在某个本地临时路径中以统一您的文件名,您可以使用会话ID。 />


[更新]



Hi,

First check you "Price" column data type it should be numeric (Int,Decimal,Float,Double) otherwise it will not show the proper values.

Apart from that keeping dataset in session/ViewState is not a good idea, so you can write data set in file and store it in some local temp path to uniform your file name you can use Session Id.

[Update]

var tt= TempAdsDS.Tables[0].AsEnumerable().Where( p =&gt; p.Field<int>("Price")>=Minimum && p.Field<int>("Price")<=Maximum)





谢谢,

Suvabrata



Thanks,
Suvabrata


Datatable dt1 = new Datatable();

dt1 = TempAdsDS.Tables [0];

string filter =Price > +最小+和价格< +最大;



DataView视图=新DataView(dt1);

view.RowFilter = filter;

dt1 = view.ToTable();
Datatable dt1=new Datatable();
dt1=TempAdsDS.Tables[0];
string filter = ""Price > " + Minimum + " and Price < " + Maximum";

DataView view = new DataView(dt1);
view.RowFilter = filter;
dt1 = view.ToTable();


这篇关于数据表过滤器Doest在数据集上无法正常工作。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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