日期:2014-05-20  浏览次数:20978 次

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[……