views:

31

answers:

1

Hi i have a entity that cold Users that have a navigation property UsersData that have a field "LastLoginDate" what i want to do is use EntityDataSource to display some information of the users inside a GridView (I don't want to do it from code behind with linq) . I tried to use Include property of EntityDataSource but i don't know how use them in my gridview to select LastLoginDate field can anyone help me ? it's need to be a very basic thing to do, show a relation table field... This is my code:

    <asp:EntityDataSource ID="EntityDataSource" runat="server" 
        ConnectionString="name=MyModelEntities" DefaultContainerName="ModelEntities" 
        EnableDelete="True" EnableInsert="True" 
        EnableUpdate="True" EntitySetName="Users" Include="UsersData" AutoGenerateWhereClause="True" 
        EnableFlattening="False">
    </asp:EntityDataSource>
A: 

If the relation between Users and UsersData is of multiplicity 1:1 you can try to add to your grid field like:

<asp:BoundField DataFiled="UsersData.LastLoginDate" HeaderText="Last Login" />

Where UsersData is name of your navigation property in User entity. Similarly you can try use Eval expression in TemplateField:

<%# Eval("UsersData.LastLoginDate") %> 
Ladislav Mrnka