读书人

linq查到的结果怎么显示在控件中

发布时间: 2012-06-15 19:37:05 作者: rapoo

linq查到的结果如何显示在控件中
如何显示出来呢?
不一定是gridview,label也行啊!今天第一次知道有linq这种东西,写了一点代码,也不知对不对,我想返回cbInfos

C# code
var cbInfos = from c in dsTransVolumes.Tables[0].AsEnumerable()                       join r in dsAssets.Tables[0].AsEnumerable() on                       c.Field<string>("ID") equals r.Field<string>("ID")                       select new                       {                           AsseTurnover = c.Field<decimal>("TransVolumes") / r.Field<decimal>("Assets"),                           ID = c.Field<string>("ID"),                           TransVolumes = c.Field<decimal>("TransVolumes"),                           Assets = r.Field<decimal>("Assets")                       };


[解决办法]
gridview直接绑定就行
gridview.datasource=cbInfos ;
gridview.databind();

label需要用foreach循环内容。。。
[解决办法]
探讨
如何显示出来呢?
不一定是gridview,label也行啊!今天第一次知道有linq这种东西,写了一点代码,也不知对不对,我想返回cbInfos

C# code
var cbInfos = from c in dsTransVolumes.Tables[0].AsEnumerable()
join r in dsAssets.Tables[……

读书人网 >.NET

热点推荐