Mar 07, 2012, 5:20 AM
[Solved]Entity Framework navigation object not displayed in datagrid
Hi all,
I am new with ext.net and I am facing a problem.
I am developping asp.net app with entity framework. So far my model is very simple and attached as image
I would like to display my registries in a grid view, and add the communication_desc (always 'LETTER') corresponding to communication navigation property of entity Registry.
I successfully did it in regular asp.net, but couldn't find the way to display in an ext.net datagrid the attribute communication_desc of the object communication.
Find below the code that works in asp.net, but not in ext.
Thanks a lot
I am new with ext.net and I am facing a problem.
I am developping asp.net app with entity framework. So far my model is very simple and attached as image
I would like to display my registries in a grid view, and add the communication_desc (always 'LETTER') corresponding to communication navigation property of entity Registry.
I successfully did it in regular asp.net, but couldn't find the way to display in an ext.net datagrid the attribute communication_desc of the object communication.
Find below the code that works in asp.net, but not in ext.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:EntityDataSource ID="RegistryDataSource" runat="server" ContextTypeName="RegistryModel.RegistryEntities"
EnableFlattening="False" EntitySetName="Registries" Include="batch_logsheet,Communication"
ConnectionString="name=RegistryEntities" DefaultContainerName="RegistryEntities">
</asp:EntityDataSource>
</div>
<asp:GridView ID="GridView1" runat="server" DataSourceID="RegistryDataSource"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="cover_date" HeaderText="Cover Date"
SortExpression="cover_date" />
<asp:BoundField DataField="ack_date" HeaderText="Acknowledge Date"
SortExpression="ack_date" />
<asp:BoundField DataField="source_id" HeaderText="Source"
SortExpression="source_id" />
<asp:BoundField DataField="cover_type_id" HeaderText="Cover Type"
SortExpression="cover_type_id" />
<asp:TemplateField HeaderText="Com_desc">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Communication.communication_desc") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:GridPanel ID="GridPanel1" runat="server" Height="300">
<Store>
<ext:Store ID="Store2" runat="server" DataSourceID="RegistryDataSource">
<Reader>
<ext:JsonReader IDProperty="registry_id">
<Fields>
<ext:RecordField Name="cover_date" />
<ext:RecordField Name="ack_date" />
<ext:RecordField Name="source_id" />
<ext:RecordField Name="cover_type_id" />
<ext:RecordField Name="received_by" />
<ext:RecordField Name="ack_by" />
<ext:RecordField Name="ack_type" />
<ext:RecordField Name="scanned_data" />
<ext:RecordField Name="communication" IsComplex="true"/>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column DataIndex="cover_date" Header="Cover Date" />
<ext:Column DataIndex="ack_date" Header="Aknowledge Date" />
<ext:Column DataIndex="source_id" Header="Source" />
<ext:Column DataIndex="cover_type_id" Header="Cover Type" />
<ext:Column DataIndex="received_by" Header="Received By" />
<ext:Column DataIndex="ack_by" Header="Aknowledge By" />
<ext:Column DataIndex="ack_type" Header="Aknowledge Type" />
<ext:Column DataIndex="scanned_data" Header="Scanned Data ?" />
<ext:Column DataIndex="communication" Header="communication" />
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>
Basically I'm looking for the equivalent of this partin ext.net:<asp:TemplateField HeaderText="Com_desc">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Communication.communication_desc") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
FYI, this is the output I get:Thanks a lot
Last edited by bubu_noumea; Mar 08, 2012 at 4:09 AM.
Reason: Solved