Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Here My code behind:
C#
Datalist1.datasource=obj.GetFirstData();
Datalist1.databind();

Here i am returning value:
C#
public List<DetailsModel.Xyz> GetFirstData()
{
  var x = from n in obj.Temples select n;
  return x.ToList<DetailsModel.Temple>();
}

In my xyz contain n0. of records but i want to display only 8 among them Give me something that replace var x code or any other way to show it Please help me.
Posted
Updated 19-Oct-12 7:50am
v2

Start here[^].
 
Share this answer
 
Comments
Harshal Solao 19-Oct-12 14:39pm    
nice it gives me first 8 records but my requirement is it should be random What to do?
R. Giskard Reventlov 19-Oct-12 14:49pm    
So why didn't you mention that in the question? Do you mean 8 rows chosen at random? Curious as to the purpose.
Just include the take clause.
C#
var x = from n in obj.Temples take 8 select n;
 
Share this answer
 
Comments
Harshal Solao 20-Oct-12 0:31am    
but it gives me error Why?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



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