LinqDataSourceSelectEventArgs Class
Provides data for the Selecting event.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
The LinqDataSourceSelectEventArgs object is passed to event handlers for the Selecting event of the LinqDataSource control. You use the LinqDataSourceSelectEventArgs object to manually specify what data is returned, and how the data is sorted and paged when it is returned. You can programmatically add or remove parameters to the GroupBy, OrderBy, OrderGroupsBy, Select, and Where clauses by using the GroupByParameters, OrderByParameters, OrderGroupsByParameters, SelectParameters, and WhereParameters collections.
The Result property enables you to change the data object that is used for the query. If you assign an object to the Result property, that object will be used for queries instead of the object specified in the TableName property of the LinqDataSource control.
The Arguments property enables you to customize how returned data is sorted and paged. The data-bound control passes sorting and paging properties through the Arguments property. If you have to manually handle sorting or paging, set the AutoSort property or AutoPage property of the LinqDataSource control to false. You can then perform the customized query for sorting or paging in a handler for the Selecting event.
If the RetrieveTotalRowCount property is set to true, you must return a value for the TotalRowCount property.
The following example shows how to set the Result property to the result of a search made by using language-integrated query (LINQ).
protected void LinqDataSource_Selecting(object sender, LinqDataSourceSelectEventArgs e) { ExampleDataContext exampleContext = new ExampleDataContext(); e.Result = from p in exampleContext.Products where p.Category == "Beverages" select new { ID = p.ProductID, Name = p.Name }; }
The following example shows how to set the Result property to an array of string values that is defined in the Web page.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
System::EventArgs
System.ComponentModel::CancelEventArgs
System.Web.UI.WebControls::LinqDataSourceSelectEventArgs
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.