LinqDataSource – Can you limit the amount of records returned?

I had this same issue. The way I got round this was to use the Selecting event on the LinqDataSource and return the result manually.

e.g.

protected void lnqRecentOrder_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
    DataClassesDataContext dx = new DataClassesDataContext();
    e.Result = (from o in dx.Orders
                where o.CustomerID == Int32.Parse(Request.QueryString["CustomerID"])
                select o).Take(5);
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)