LinqDataSource - Can you limit the amount of records returned?

By : Otto

I'd like to use a LinqDataSource control on a page and limit the amount of records returned. I know if I use code behind I could do something like this:

IEnumerable<int> values = Enumerable.Range(0, 10);
IEnumerable<int> take3 = values.Take(3);

Does anyone know if something like this is possible with a LinqDataSource control?


I'm going to use the LinqDataSource with the ListView control, not a GridView or Repeater. The LinqDataSource wizard does not provide the ability to limit the number of records return. The Advanced options only allow you to enabled deletes, inserts, and updates.

By : Otto


I know that if you use a paging repeater or gridview with the linqdatasource it will automatically optimize the number of results returned, but I'm also pretty sure in the datasource wizard you can go to advanced options and limit it to


which should allow you to do what you need

By : lomaxx

You can put event Selecting of LinqDataSource:

protected void ldsLastEntries_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    e.Arguments.MaximumRows = 10;
By : 10gler

protected void DocsData_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    e.Arguments.MaximumRows = 5;

This video can help you solving your question :)
By: admin