0
<asp:EntityDataSource ID="EntityDataSource2" runat="server" 
      ConnectionString="name=InfowareEntities" 
      DefaultContainerName="InfowareEntities" EnableFlattening="False" 
      EntitySetName="StudentModules" 
      Select="it.[AdmissionNo], it.[ModuleCode], it.[Status]"
      Where="it.[Status]==@Status AND it.[AdmissionNo]==@AdmissionNo">
           <WhereParameters>
               <asp:Parameter  Name="Status" Size="10" Type="String" />
               <asp:Parameter  Name="AdmissionNo" Size="7" Type="int64" />
            </WhereParameters>
  </asp:EntityDataSource

I need to get module description of this module code from Module table, here Module code is primary key in Module table and foreign key in StudentModules table.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Taqi Gates
  • 87
  • 1
  • 8

1 Answers1

0

You need to add an Include="Module" then you can reference "Module.Description" (or whatever). See https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.entitydatasource.include(v=vs.110).aspx and Columns of two related database tables in one ASP.NET GridView with EntityDataSource

Community
  • 1
  • 1
Steve Greene
  • 12,029
  • 1
  • 33
  • 54
  • `` ** This throws an error** – Taqi Gates Oct 05 '15 at 06:35
  • 'Module.ModuleDescription' could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly. Near member access expression, line 1, column 62. – Taqi Gates Oct 05 '15 at 06:40
  • Have you configured the relationship in Entity Framework? http://www.entityframeworktutorial.net/entity-relationships.aspx – Steve Greene Oct 05 '15 at 13:08
  • Yes, I have a navigation key named Module which relates ModuleCode in StudentModules and Modules table. I am using Include="Module" and in Select I am adding Module.ModuleDescription but it throws and error. – Taqi Gates Oct 06 '15 at 06:53
  • Your include might need to be Include="StudentModules.Module" depending on what the models look like. If that doesn't work edit your question with the models displayed. – Steve Greene Oct 06 '15 at 14:07