Linq查询以获取所有记录 [英] Linq query to get all the records

查看:353
本文介绍了Linq查询以获取所有记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个名为"Customers"的表,该表有6列和15行.我想使用linq查询在Gridview中显示所有athe记录.我正在使用此查询,但它没有给我所有记录.如何显示Gridview中的所有记录.



var type =(从p中的实体.客户选择p)
this.Gridview1.DataSource = type;
this .GridView1.DataBind();

Hi,

I have a table named "Customers" which has 6 columns with 15 rows. I want to show all athe records in Gridview using linq quieries. I am using this query but it is not giving me all the records. How can I show all the records in Gridview.



var type = (from p in entities.Customers select p)
this.Gridview1.DataSource = type;
this.GridView1.DataBind();

推荐答案

从我可以看到,该语句没有任何问题.您应该获取所有记录.您确定GridView在固定高度表/div中不存在吗?一旦gridview用行填充,它可能会从表/div的底部滚动下来,并且基本上被修剪了.
From what I can see there is nothing wrong with that statement. You should be getting all records. Are you sure the GridView isnt within a fixed height table/div? Once the gridview fills with rows it may be rolling off the bottom of the table/div and is basically being trimmed.


var type = from p in entities.Customers select p;
this.Gridview1.DataSource = type;
this.GridView1.DataBind();




这段代码在我的系统上运行非常好.

请进行我的小改动.

-Sagar Solanki




this code is absolutely fine running at my system.

pl make the minor changes that I did.

-Sagar Solanki


尝试一下

Try this

var type = from p in entities.Customers select p;
this.Gridview1.DataSource = type.AsDataView();
this.GridView1.DataBind();








or


var type = from p in entities.Customers 
                          select new
                          {
                               id = p.id,
                               name = p.name,
                               .
                               .
                               .
                          };
this.Gridview1.DataSource = type.AsDataView();
this.GridView1.DataBind();


这篇关于Linq查询以获取所有记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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