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 9, 2016, 4:31 AM
Thank You very much All
Santhakumar MunuswamyPosted Jan 9, 2016, 2:29 AM
Thanks for nice share
Gowtham KPosted Jan 6, 2016, 11:44 AM
Nice Share
Karthikeyan KPosted Jan 6, 2016, 9:49 AM
Good one...
Raja TPosted Jan 6, 2016, 8:44 AM
Nice, Thanks for sharing
Debasis SahaPosted Jan 6, 2016, 8:26 AM
Nice