Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
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();
Posted

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.
 
Share this answer
 
C#
var type = from p in entities.Customers select p;
this.Gridview1.DataSource = type;
this.GridView1.DataBind();



this code is absolutely fine running at my system.

pl make the minor changes that I did.

-Sagar Solanki
 
Share this answer
 
Try this

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


or


C#
var type = from p in entities.Customers 
                          select new
                          {
                               id = p.id,
                               name = p.name,
                               .
                               .
                               .
                          };
this.Gridview1.DataSource = type.AsDataView();
this.GridView1.DataBind();
 
Share this answer
 
v3
Comments
qwerzxcxyz 9-Jun-15 22:38pm    
can about where this id and name came from?

in this statement: select new
{
id = p.id,
name = p.name,
.
.
.
};
Thanks. Just a begginer


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900