display data in a gridview using ado.net EntityDataSource control
EntityDataSource control is a data source control available in ASP.Net. In ASP.Net applications, the EntityDataSource control is used to bind data retrieved from an Entity Data Model to the data bound controls.
In this article, we will learn how to use the EntityDataSource control and display data in a GridView control.
Steps to follow:
Place the Entity Data Source control on a web form. Specify the data source using the Configure Data Source option as shown in below fig.
In the second screen of Configure Data Source dialog box, select the fields to be retrieved from the table and click on the finish button.
Now place the GridView control on the web form. Set the GridView control data source property to EntityDataSource1 by using Choose Data Source option of the GridView control.
If we open the source file of web form, you can see the markup generated for gridview and entity data source control. In the below code the DataSourceID of the GridView control is set to EntityDataSource1.
Run the application. The output generated is shown in the figure below.
In this article, we will learn how to use the EntityDataSource control and display data in a GridView control.
Steps to follow:
Place the Entity Data Source control on a web form. Specify the data source using the Configure Data Source option as shown in below fig.

In the second screen of Configure Data Source dialog box, select the fields to be retrieved from the table and click on the finish button.
Now place the GridView control on the web form. Set the GridView control data source property to EntityDataSource1 by using Choose Data Source option of the GridView control.
If we open the source file of web form, you can see the markup generated for gridview and entity data source control. In the below code the DataSourceID of the GridView control is set to EntityDataSource1.
< asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="CustomerId" DataSourceID="EntityDataSource1"> < Columns> < asp:CommandField ShowDeleteButton="True" ShowEditButton="True" /> < asp:BoundField DataField="CustomerId" HeaderText="CustomerId" ReadOnly="True" SortExpression="CustomerId" /> < asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> < asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" /> < /Columns> < /asp:GridView> < asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=SalesOrderManagementEntities" DefaultContainerName="SalesOrderManagementEntities" EnableDelete="True" EnableInsert="True" EnableUpdate="True" EntitySetName="Customer"> < /asp:EntityDataSource>
Run the application. The output generated is shown in the figure below.

Entity Framework Articles
- entity framework entity data model
- entity framework orm object relational mapper
- querying entity data model using objectcontext
- using ado net entity data model in windows applications.html
- create entity data model using ado.net entity framework designer in visual studio
- create-sales-order-management-data-model-using-edmgen-tool.html
- ways of querying entity data model
- query entity data model using linq to entities
- query entity data model with object services and entity sql
- query entity data model using linq methods
- parameterized objectquery against a entity data model
- query entity data model entity client
- linq to entities query with projections in c#
- entity framework - save changes to entities
- entity framework - insert new objects
- add an entity to associated entities
- deleting entities using deleteobject() method of objectcontext
- entity framework load method
- eager loading using include method in entity framework
- entity framework - retrieving a single entity
Most Viewed
Azure Q & A
Azure Platform
Grid-View
GridView CommandField example
Details-View
GridView and DetailsView Master/Detail page using SqlDataSource control
POCO
POCO overview and advantages - POCO class, Entity Framework in Enterprise Applications
Entity Framework
Query entity data model using linq to entities
Array List
Difference between arraylist and list collection
Web Services
How to create a Web service using Visual Studio.net
Form-View
FormView DataBound Event
Object Oriented Programming
Calling base class constructor in C#
Linq
Convert a sequence to a generic list using ToList()method
Project Ideas
Project ideas for students
AccountingSoftware
Accounting Software
MVC
Creating an ASP.Net MVC 3 application
.Net
Using assemblies in .net applications
ASP .Net
How to implement form validation using ASP.Net 2.0 Validation Controls
VB .Net
Constructors in Visual Basic.Net