ADO.NET :: Use Linking Table In An EntityDataSource?
Nov 17, 2010
I have an A B AB (Many-to-Many?) table setup (where AB is the Linking Table for records in A and B by their IDs). Entity Framework 4.0 seems to create the EDM correctly (making an entity for A and B, and navigation property for AB). My problem is getting a GridView bound to an EntityDataSource to display columns from A with associated B records.
Here's my code:
[Code]....
The resulting GridView only shows columns from A. How do I get it to also show the associated columns from B? Do I have to explicitly define the columns or is AutoGenerateColumns smart enough to figure it out?
View 2 Replies
Similar Messages:
Nov 22, 2010
I am using EF 4 and EntityDataSource in a Page (WebForms).
This page contains a DropDownList that display UserName.
Data from this DropDownList it is from "aspnet_Users".
At the moment I am using a single EntityDataSource code belove:
<asp:EntityDataSource ID="EntityDataSourceListUsers" runat="server" ConnectionString="name=CmsConnectionStringEntityDataModel"
DefaultContainerName="CmsConnectionStringEntityDataModel" EnableFlattening="False"
EntitySetName="aspnet_Users" Select="it.[UserId], it.[UserName]">
</asp:EntityDataSource>
I need to FILTER the UserName associated to a specific ROLE and displaying it in the DropDownList therefore using others tables"aspnet_UsersInRoles" and "aspnet_Roles".
How to do it?
Would be great have a simple solution since I am a beginner.
View 1 Replies
Feb 23, 2011
I am using an ADO Entity Model for my ms-sql database.
My database has a Resellers table which has ResellerID (primary key, int) and Name columns along with other data.
I also have an Orders table which contains OrderID (primary key, int), OrderDate, ResellerID (foreign key to Resellers.ReselerID).
If I just do a query like:
[Code]....
I am able to reference order.Reseller.Name just fine with no problems.
However I have an EntityDataSource on my page as follows:
[Code]....
Notice the Include="Reseller" attribute in the datasource... I also have a GridView tied to that datasource as follows: I cut some of it off for breavity:
[Code]....
Now what I have listed above will run with no errors, but what I want to do is replace the column that displays "ResellerID" with the equivilant to order.Reseller.Name. In other words I want my grid to display the reseller's name rather than the numeric ID.
I have tried to change the DataField to "Reseller.Name" but that will generate the following error:
A field or property with the name 'Reseller.Name' was not found on the selected data source.
Is there anyway to do this without me writing a custom select statement in my code behind?
View 2 Replies
Mar 25, 2011
I have a simple ASP.NET (Web Form) application. I created a separate project for my DAL. In the DAL, I have created an entity called Sites.
Now, I want to bind that to a form using an EntityDataSource control but it isn't visible. What am I doing wrong?
I made sure to reference the DAL.dll in the web project and include it in the code behind for the form. It's been a while since I've been in ASP.Net :-)
View 1 Replies
Mar 18, 2011
What my code does is that the EntityDataSource has a Where Parameter tied to the first DropDownList and it populates the second DropDownList, but when the first DDL changes, the EntityDataSource doesn't change the values of the second DDL. Worth mentioning this is inside a ModalPopupExtender which is inside an UpdatePanel. Maybe there is a way in just putting all the data in the second DropDownList and filter it depending on the value of the first one... or something like that... so there's no need of refreshing the data.
<asp:DropDownList ID="PaqueteKitDropDownList" runat="server" DataSourceID="PaqueteEntityDataSource"
DataTextField="Nombre" DataValueField="ID_Paquete" />
<asp:EntityDataSource ID="PaqueteEntityDataSource" runat="server" ConnectionString="name=CCEntities"
DefaultContainerName="CCEntities" EnableFlattening="False" EntitySetName="Paquetes">
</asp:EntityDataSource>
<br />
<asp:Label ID="Label66" AssociatedControlID="PlanKitDropDownList" runat="server"
Text="Plan:" />
<asp:DropDownList ID="PlanKitDropDownList" runat="server" DataSourceID="PlanKitEntityDataSource"
DataTextField="Duracion" DataValueField="Costo" />
<asp:EntityDataSource ID="PlanKitEntityDataSource" runat="server" ConnectionString="name=CCEntities"
DefaultContainerName="CCEntities" EnableFlattening="False" EntitySetName="Duracion_Plan"
Where="it.ID_Paquete == @ID" OrderBy="it.Duracion ASC">
<WhereParameters>
<asp:ControlParameter DbType="Guid" Name="ID" ControlID="PaqueteKitDropDownList"
PropertyName="SelectedValue" />
</WhereParameters>
</asp:EntityDataSource>
View 2 Replies
Nov 30, 2010
is it possible to use OFTYPE in where clause of an entitydatasource? I mean something like this:
srcUsers.Where = "OFTYPE(Doctor)";
View 1 Replies
Apr 23, 2010
I'm utterly new to APS.NET and in particular the MVC model...! I have a Telerik RadGrid control that I'm using. Until now (following NerdDinner) I was having the Model passed back to the view and this provided access to the various properties I wanted.
eg: Inherits="System.Web.Mvc.ViewPage<MySqlMvc.Helpers.PaginatedList<MySqlMvc.Models.Customer>>
.. lets me loop around the Model object and extract Customer data. This RadGrid control, however, needs me to use an EntityDataSource (hooked up via the designer). Does this have implications for maintaing the MVC pattern? I'm a little confused about how the EntityDataSource works in relation to my Model.EDIT: I do know there is an MVC version of the RadGrid but we also need the RadScheduler and a few others.. besides that, I'd still like to know the impact.
View 1 Replies
Mar 28, 2011
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 Memebership Provider ( Membership.GetUser(); ).
Now I cannot inf any Parameter in EntityDataSource that would allow me to dot that (in Where/Automatically generate a Where expression using provided parameter ).
View 1 Replies
Jan 5, 2011
I use MS SQL, EF 4 and C#.
I have a table in SQL fro "Categories" and I need populate a TreeView in my Asp.net page.
My question are:
1 - How can i populate the TreeView?
2 - How can i use the TreeView to modify the hierarchy of my Categories?
NOTE: I use "hierarchyid" SQL Columns!
CREATE TABLE dbo.CmsCategories
(
CategoryId int NOT NULL IDENTITY (0,1) -- Seed = 0 and Increment= 1
CONSTRAINT PK_CmsCategories_CategoryId PRIMARY KEY,
Title nvarchar(40) NOT NULL,
MetaDescription nvarchar(160) NOT NULL,
MetaKeyword nvarchar(128) NOT NULL,
Summary nvarchar(256) NOT NULL,
IsPublished bit NOT NULL
CONSTRAINT DF_CmsCategories_IsPublished DEFAULT 1,
CategoryNode hierarchyid NOT NULL,
CategoryNodeLevel AS CategoryNode.GetLevel()
);
View 1 Replies
Dec 29, 2010
I have an EntityDataSource and I need set WHERE to a Local Variable Type: GUID.
My problem is I am not able to send my local variable Guid to EntityDataSource for a WHERE OPERATION.
I also tried to to use a ControlParameter<asp:ControlParameter Name="UserId" /> and have a Label with Text property on my Guid converted in String. But does not work.
<asp:EntityDataSource ID="EntityDataSourceListAuthors" runat="server"
AutoGenerateWhereClause="True"
ConnectionString="name=CmsConnectionStringEntityDataModel"
DefaultContainerName="CmsConnectionStringEntityDataModel"
EnableFlattening="False" EntitySetName="CmsAuthors" Where=""
EntityTypeFilter="" Select="">
<WhereParameters>
<asp:Parameter Name="UserId" />
</WhereParameters>
</asp:EntityDataSource>
View 1 Replies
Mar 3, 2011
I've used EF4 EntityDataSources to do DataBinding with success, but here's a case where I'm stumped:
Table "CurrentComplaintsByUsers" has a foreign key over to a "Complaints" table. So in EF, I can access a CurrentComplaintByUser record, and navigate to its parent complaint like so:
var ccU = dataContext.CurrentComplaintsByUsers.First();
var parentComplaint = ccU.Complaint;
When I whip up an EntityDataSource based on CurrentComplaintsByUsers to bind a gridview, I want to get over from the "Complaint" object to an Assocation of Complaint called "Status". Here's a StatusID in my Complaint table, and so in code I can hit a complaint's status like so, including the Status properties:
string statusLabel = parentComplaint.Status.LabelText;
FAILURE: when I try to bake this all into an EntityDataSource, I can't get from my starting item "CurrentComplaintsByUsers" over to "Status". Here's my EDS:
<asp:EntityDataSource ID="edsCurrentCases" runat="server"
ConnectionString="name=EOCaseDataModel" DefaultContainerName="EOCaseDataModel"
EnableFlattening="False" EntitySetName="CurrentComplaintsByUsers"
Include="Complaint, Status">
</asp:EntityDataSource>
My error is this:
System.InvalidOperationException
"A specified Include path is not valid.
The EntityType 'EOCaseApp.CurrentComplaintsByUser' does not declare a navigation property with the name 'Status'."
I'm trying to get to the point where this works in my Gridview:
<%# ((CurrentComplaintsByUser)Container.DataItem).Complaint.Status.LabelText %>
So, using declaritive markup only, how do I get to a related objects associations from the EDS? (I can do it in code, just trying to use the EDS exclusively when I can)
Other notes: if I remove "Status" from the "Include" in the EDS, then I get a NULL ERROR when it hits ..Complaint.Status.LabelText in my Gridview, pretty much what you'd expect.
View 1 Replies
Aug 5, 2010
I try to do exactly like this thread : http://forums.asp.net/p/1551018/3802862.aspx#3802862But when i apply the solution it do work but i can't delete an entry anymore in the GridView..
View 4 Replies
Feb 5, 2011
i'm using an entitydatasource to save an entity which has an nullable integer property with the default value 0,this property is bound to a textbox in a formview.I assume that when I leave the textbox blank the datasource should understand that I want the property to have null and set it to 0 by default, but it acts different way, it doesn't save the enity at all and gives the entity in Updated and Inserted events as null:
[Code]....
View 3 Replies
Nov 9, 2010
I have a Entity Data Model with a number of tables in it. I have a web page that only has an EntityDataSource on it.In the code behind I am collecting some data that I am going to write to a SQL table What I want to do is call the EntityDataSource_Insert event and when it is fired it will call the EntityDataSource_Inserting event.
[Code]...
View 9 Replies
Jan 8, 2011
I have an application that uses EntityDataSource in many places. In the EDS, I manually build the Where clause based on user input from TextBox'es.
I would like the user to be able to enter "*" (asterisks) instead of "%" when querying data.
Is there an easy as using Entity SQL or the EDS itself to do a search/replace? I know I could actually change the TextBox after the data is entered, but when the user sees his text was changed from an * to a % I don't think he will understand.
I have tried using the T-SQL Replace command and doing something like this:
<asp:EntityDataSource ID="EDSParts" runat="server"
ConnectionString="name=TTEntities" DefaultContainerName="TTEntities"
EnableFlattening="False" EntitySetName="Parts"[code]....
But I get a "Server tag is not well formed" message. I can't find an equivalent "replace" function in the Entity SQL reference....
View 2 Replies
Mar 23, 2011
I am new to EntityFrameWork so bear with me here. I have a webpage (page1.apsx) n page2.aspx.
Page1.aspx is showing gridview of following items:
EntityID
Name
Description
Whenever user is selecting some Entity then I am passing this EntityID to Page2.aspx. In Page2 I am having EntityDataSource and GridView. Also, the value needs to be populated is from different tables in this page. How you deal with this in EntityDataSource and populating it in GridView?
View 3 Replies
Jun 12, 2010
I'v been using SqlDataSource and ObjectDataSource for a while.I would like to know about LinqDataSource and EntityDataSource. Therefore I have 2 questions to ask.1) Why do we need to use those twos? 2) In which cirmustances (Requirements) developers are using LinqDataSource and EntityDataSource?
View 1 Replies
Oct 3, 2010
how to set entitydatasource select method to a function?
could i use objectdatasource with entity model?
View 1 Replies
Nov 24, 2010
I use C#, asp.net 4, EF4,
I have a page with a DetailsView control is connected with EntityDataSource. All is working.
In code behind I need to create a variable that will populate with data from EntityDataSource, lets imagine field UserId.
My questions: How to retrieve and use data from EntityDataSource?
View 1 Replies
Aug 31, 2010
I am using and EntityDateSource and I add where condition to filter the data at runtime and then bind the grid to the dataSource, but I am getting following error:-
The argument types 'Edm.DateTime' and 'Edm.String' are incompatible for this operation.
Search condition looks like this:-
it.[MyDate]='8/13/2010 00:00:00'
View 2 Replies
Sep 28, 2010
i have a problem that only shows if EntityDataSource present on aspx pages ,interesting thing it's just occures when i'm refreshing the page (F5) or viewing it again and it's driving me crazy it's seems to be a bug with entity framework because i tried it with another project and i just get the same error:
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
[Code]....
View 1 Replies
Feb 28, 2011
I'm using EntityDataSource to retrieve my items, and i want to get the items for a particular region. (items and regions has a many to many relationship, thus item has a regions navigation property). and I'm using "IN" to filter the items. tried several combinations and it kept on throwing various errors. how can i get this sorted out:
Below is My DataSource:
[code]....
View 1 Replies
Mar 11, 2011
T-SQL
[Code]....
And i want to convert to eSQL for EntityDatasource
[Code]....
But it is error.
View 1 Replies
Jan 24, 2011
I have this code, and I need the "it.MembershipOption.Id" value in the "where" clause to be the <%# Eval("Id") %> from ListViewEventsOuter. I tried to add the Eval in the "where" clause but it throws an error.
How is this done?
[code]...
View 1 Replies
Mar 15, 2010
What would be the best way to extend the EntityDataSource control? I have a site that implements Entity Framework and I current create my model container and add it to the HTTPCurrent context. When I create EntityDataSource controls on the page I have to go into the code behind and set the OnContextCreating to add MY context to the EntityDataSource instead of the one that EntityDataSource creates. This is because in my model I have extended the Partial Classes to support Validation and custom Save/Delete methods.I would ideally like to create a custom control that I can drop onto a page that has its context already set to the context that I created.
View 1 Replies