CODEDIGEST
Home Articles CodeDigest Tutorials FAQs
Skip Navigation LinksHome » CodeDigest » How to Cancel DataBind when using LINQDataSource Control?   You are not logged in.
Search
 

Sponsored Links
 

Technologies
 

CodeDigest Navigation
 

Technology News
No News Feeds available at this time.
 

Community News
No News Feeds available at this time.
 
How to Cancel DataBind when using LINQDataSource Control?
How to Cancel DataBind when using LINQDataSource Control?
Submitted By Satheesh Babu B
On 12/7/2009 8:36:58 AM
Tags: ASP.Net,CodeDigest,LINQDataSource  

How to Cancel DataBind when using LINQDataSource Control?

At times, we will require cancelling the databind of LINQData source control. The below little code snippet 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"
                GroupBy="new(Location,Dept.Department)"
       
        Select="new (key.Location as City,key.Department as Department, Max(Age) as MaxAge)"
        onselecting="LinqDataSource2_Selecting">
         </asp:LinqDataSource>

CodeBehind
 protected void LinqDataSource2_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {
        e.Cancel = true;
    }


Happy Coding!!

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..