Questions tagged [entitydatasource]

EntityDataSource is an ASP.NET web server control available in .NET Framework 3.5 SP1 or later. It supports declarative data-binding of other web controls to an Entity Data Model of Entity Framework.

EntityDataSource is an ASP.NET web server control available in .NET Framework 3.5 SP1 or later.

EntityDataSource belongs to a family of server controls - like ObjectDataSource, SqlDataSource or XmlDataSource - which allow data-binding of web controls to a data source.

EntityDataSource is specifically tailored to interact with an Entity Data Model provided by Entity Framework. It supports declarative definition of CRUD operations in an ASPX web page as well as sorting, paging, data projections and various kinds of parameters to specify parametrized queries - like ControlParameter, QueryStringParameter, ProfileParameter and others.

Example

The following EntityDataSource configures data-binding to an Entity Data Model called "NorthwindEntitiesContext", selects an Order including all OrderDetails by an ID entered in a TextBox control and allows updating, inserting and deleting of Order objects:

<asp:EntityDataSource ID="NorthwindEntityDataSource" runat="server" 
    ConnectionString="name=NorthwindEntitiesContext" 
    DefaultContainerName="NorthwindEntitiesContext" 
    EntitySetName="Orders" 
    Include="OrderDetails"
    EnableUpdate="True" EnableInsert="True" EnableDelete="True"
    AutoGenerateWhereClause="True">
    <WhereParameters>
        <asp:ControlParameter Name="OrderID" ControlID="TextBoxOrderID" 
            DbType="Int32" PropertyName="Text" />
    </WhereParameters>
</asp:EntityDataSource>

Resources

159 questions
29
votes
3 answers

Convert DBContext to ObjectContext for use with GridView

I have a webforms project using EF codefirst to persist data. I'd like to use a GridView and EntityDataSource, in order to save writing CRUD. Is this possible? Can I convert my DBContext to an ObjectContext that is expected by the…
Myster
  • 17,704
  • 13
  • 64
  • 93
9
votes
3 answers

Entity DataSource not working with Entity Framework 6 Upgrade

I recently upgraded our Webforms application from EF 4.4 to EF6 and I got so many compile time build errors with the Entity Datasource controls. Generally I am getting these error in all occurrences when trying to access the context object…
Maninder
  • 1,261
  • 5
  • 20
  • 34
7
votes
4 answers

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. with EntityDataSource

I have a problem that only shows if EntityDataSource present on ASP.NET (*.aspx) pages. The interesting thing it's just occurs when I'm refreshing the page (F5) or viewing it again and it's driving me crazy it seems to be a bug with Entity…
Milady
  • 79
  • 1
  • 1
  • 2
6
votes
3 answers

Filtering data using EntityDataSource and WHERE

Hi I have an EntityDataSource. I need programmatically SEND a variable (@SelectedValue) to be used in a WHERE Filter for the EntityDataSource . Can you post a simple core to show me how to do it? Thanks for your time! To create WhereParameters on…
GibboK
  • 71,848
  • 143
  • 435
  • 658
6
votes
1 answer

Visual Studio 2013 and Entity Framework

I'm using VS 2013 and SQL Svr 2012 and trying use EF to populate a gridview. As this is a very simple test, I have just one table with a key and a couple of data fields. The process of creating the model seems to work fine - it shows as expected…
6
votes
1 answer

How to populate an updateable FormView from an EntityDataSource with filter

I'm trying to create a member page for updating account details. I want to populate a form with the member's data, but I don't know how to set a filter on the EntityDataSource to limit the query. When I set the select statement based on the member…
John B
  • 20,062
  • 35
  • 120
  • 170
5
votes
1 answer

Relationship change from one-many into Many to many need to update listview

I have a distribution table with a pk of DistributionID and a recipients table with RecipientID as pk. This table used to be 1 to many but now needs to change to a many to many with an intermedate table. I have an EntityDataSource that supplies a…
4
votes
2 answers

Sorting a bound ASP.NET GridView on the Count of items in an Entity Framework navigation property

I have an ASP.NET page with a GridView control bound to an EntityDataSource (see simplified code below). The grid is showing a list of Parent items and includes a column to show the .Count of Children for this parent. I can get the grid to show…
Joel Brown
  • 14,123
  • 4
  • 52
  • 64
4
votes
1 answer

Filter Data using EntityDataSource

I use EF 4, C# and MS Membership Provider. I have a GridView with DataSource an EntityDataSource web control. I would like filter Data using EntityDataSource, filter show apply for the Current Logged-In User, this value should be taken using MS…
GibboK
  • 71,848
  • 143
  • 435
  • 658
4
votes
2 answers

How to implement EntityDataSource Where IN entity sql clause

I want to pass a number of values into a parameter of the EntityDataSource, e.g.: Where="it.ORDER_ID IN {@OrderIdList}" (this is a property on the EntityDataSource)
TonyS
  • 556
  • 8
  • 11
4
votes
1 answer

EntityDataSource: TotalRowCount returns -1. What's that?

I have an EntityDataSource with OnSelected event (fired after finished query). The event handler has event args of type EntityDataSourceSelectedEventArgs e. Query runs fine without error and the IEnumerable e.Results contains 1 object (I can run…
Slauma
  • 175,098
  • 59
  • 401
  • 420
3
votes
1 answer

asp.net entity framework <%# Bind("linkedTable.Field") %>

.NET 4 ASP.NET I have a DetailsView that is displaying an entity framework record for a table that has a linked lookup table. I have an asp:BoundField with the datafield set as "linkedTable.Field" and it displays a value.
Bakanekobrain
  • 423
  • 6
  • 14
3
votes
1 answer

EntityDataSource where association count > 0

I'm trying to get Items that has at least 1 Chart, Items and Charts have a 1 to many relation. I tryed this :
JoRouss
  • 2,864
  • 2
  • 22
  • 40
3
votes
2 answers

like operator in entitydatasource

I'm using an EntityDataSource in an asp .net form and a Gridview is bound to it. A where clause is used in the entityDataSource: Where="it.Name like '%@Name%' @Name is a parameter:
user1223444
3
votes
3 answers

Using parameterised LIKE clauses in an EntityDataSource

I have a basic EntityDataSource bound to a GridView. I have TextBox above the GridView for searching. My goal: a) User types "jon" b) GridView` is filtered, e.g. "Jonathan","Enjona","Jonas". I have seen several examples of how to add a parameterised…
Greg
  • 51
  • 1
  • 5
1
2 3
10 11