Reputation: 187
I have dataset in session object with all user record somewhere I have to show all ( 200 row) record some where only 5 in asp.net repeater control
I am trying to show 5 record/row but now working still showing 200 record
DataSet tempDS = (DataSet)Application["ActivityDS"];
//I tried both but now working
tempDS.Tables[0].Rows.Cast<System.Data.DataRow>().Take(5);
OR
tempDS.Tables[0].AsEnumerable().Take(5);
repSearchResult.DataSource = tempDS;
repSearchResult.DataBind();
what I have to do for showing 5 row from dataset to asp.net repeater control
Upvotes: 1
Views: 1645
Reputation: 4496
Try with:
var datasource=tempDS.Tables[0].AsEnumerable().Take(5);
repSearchResult.DataSource = datasource;
repSearchResult.DataBind();
You can also take a look to: http://msdn.microsoft.com/en-us/library/bb503062(v=vs.110).aspx
Return Value Type:
System.Collections.Generic.IEnumerable<TSource>
An
IEnumerable<T>
that contains the specified number of elements from the start of the input sequence.
So, with this method you are not modifying the original sequence, a new IEnumerable
is created and returned.
Upvotes: 1