CODEDIGEST
Home » CodeDigest
Search
 

Technologies
 

Get the ResultSet Returned by LINQDatasource Control in CodeBehind
Submitted By Satheesh Babu B
On 12/13/2009 2:28:49 AM
Tags: CodeDigest,LINQ  

Get the ResultSet Returned by LINQDatasource Control in CodeBehind

 

 

LinqDataSource control exposes some handful of events that gets raised before and after fetching the data from the database. At times, it is required to get the result returned by the LinqDataSource control from codebehind file for some specific reasons. We can use the OnSelected event to do this. This event will be raised once the data is fetched from the database.

 

 

The below code will help us to do that.

 

ASPX

 

<asp:GridView ID="GridView2" runat="server" DataSourceID="LinqDataSource2">

</asp:GridView>

<asp:LinqDataSource ID="LinqDataSource2" runat="server"

ContextTypeName="DataClassesDataContext" TableName="Employees"

onselected="LinqDataSource2_Selected">

</asp:LinqDataSource>

 

CodeBehind

protected void LinqDataSource2_Selected(object sender, LinqDataSourceStatusEventArgs e)

    {

        List<Employee> list = e.Result as List<Employee>;       

    }

 

Do you have a working code that can be used by anyone? Submit it here. It may help someone in the community!!

Recent Codes
  • View All Codes..