如何将LInq查询的返回结果集绑定到Gridview [英] How to bind return result set of LInq Query to Gridview

查看:116
本文介绍了如何将LInq查询的返回结果集绑定到Gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我想将LINQ查询结果绑定到gridview
我创建了一个类,在其中使用实体框架工作保持Linq Query的逻辑
例如:

Hi all,
i want to bind the LINQ query result to a gridview
i have created a class where i kept my logic of Linq Query using Entity frame work
example:

using(tesingmodel.testingentities TE =new tesingmodel.testingentities())
{
var query=from e in TE.emps
select e;
}


查询将返回结果集
在我的按钮逻辑中,我需要将查询绑定到gridview
如何做到这一点,建议我一个解决方案

谢谢Inadvance


Query will return a result set
in my button logic i need to bind the query to gridview
how to do this plz suggest me a solution

Thanks Inadvance

推荐答案

下面是方法::::

below is the method ::::

public static list<emp> fillgrid()<br />
{<br />
  testingentities TS=new testingentities(); <br />
var query=from e in TE.emps<br />
 select e;<br />
return query.ToList();<br />
}


解决方案是学习正在使用的工具.这是一个提示. GridView.DataSource带有IEnumerable对象.现在您可以弄清楚如何从LINQ查询中获取此类对象.
The solution is to learn the tools you are working with. Here is a hint. GridView.DataSource takes an IEnumerable object. Now you can figure out how to get such an object from the LINQ query.


这篇关于如何将LInq查询的返回结果集绑定到Gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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