Introduction
As we all know about GridView, it is a Data Control of ASP.NET which is used to display sata in tabular format.
Lambda Expression
Lambda expression facilitates functional programming. It’s an Anonymous Function.
Syntax:
(Input=>Expression )
Features:
- Using Anonyms variable/parameters.
- No need to define scope like curly braces.
- No need to return.
LINQ Query (Language Integrated Query):
In simple terms, LINQ provide us the facility to interact from front end to databases without directly using and ADO.NET Classes.
In other words, LINQ is a collection of Extension Methods.
Syntax:
From<range variable> IN <IEnumerableCollection >
The following are the basic methods of LINQ:
- From
- Where
- Select
More about LINQ.
Demonstration
Step 1: Open Visual Studio, click Add, then new Web Site:

Add LINQ to SQL Classes:

Step 2: Drag your SQL Table to dbml Layout:

It will automatically create Class , Collection and Properties.
- Class: DataContext, Departmeant
- Collection: Departments
- Proreties: DeparmentID,DeapartmentName ,CapLimits, Location
Step 3: Add a GridView Control to the form and bind accordingly:

Step 4: In Code Behind (.cs Page):
- To Bind Grid View:

- For Insert and Delete:

- For Update:

Output will look like the following:

Hopefully, this article will help you to work on GridView and LINQ.


Kundan JhaPosted Jan 8, 2016, 11:31 PM EST
Thank You very much All
Santhakumar MunuswamyPosted Jan 8, 2016, 9:29 PM EST
Thanks for nice share
Gowtham KTOP 100Posted Jan 6, 2016, 6:44 AM EST
Nice Share
Karthikeyan KPosted Jan 6, 2016, 4:49 AM EST
Good one...
Raja TPosted Jan 6, 2016, 3:44 AM EST
Nice, Thanks for sharing
Debasis SahaTOP 100Posted Jan 6, 2016, 3:26 AM EST
Nice