我想从entitydatasource获得完整的下拉列表但是>>>
我有一个问题
CommandText="SELECT d.[firstName] FROM DentistEntities.Doctors AS d WHERE d.[id] IN (SELECT s.[doctorID] FROM DentistEntities.DoctorsOfSections AS s WHERE s.[sectionID] = 2)"
这是我的asp代码
<asp:DropDownList ID="doctorlist" runat="server" Width="172px" DataSourceID="EntityDataSource2" DataTextField="firstName" DataValueField="firstName">
</asp:DropDownList>
<asp:EntityDataSource ID="EntityDataSource2" runat="server" ConnectionString="name=DentistEntities" DefaultContainerName="DentistEntities" CommandText="SELECT d.[firstName] FROM DentistEntities.Doctors AS d WHERE d.[id] IN (SELECT s.[doctorID] FROM DentistEntities.DoctorsOfSections AS s WHERE s.[sectionID] = 2)">
</asp:EntityDataSource>
但是当我编译时我有这个错误
元素类型&#39; Edm.Int32&#39;和CollectionType&#39; Transient.collection [Transient.rowtype(doctorID,Edm.Int32(Nullable = True,DefaultValue =))]&#39;不兼容。 IN表达式仅支持实体,标量和引用类型。在WHERE谓词附近,第1行,第69列。
任何帮助
谢谢
答案 0 :(得分:3)
任何有同样问题的人都可以尝试这一点(请注意子选择中的&#39; VALUE&#39;关键字):
CommandText="SELECT d.[firstName] FROM DentistEntities.Doctors AS d WHERE d.[id] IN (SELECT VALUE s.[doctorID] FROM DentistEntities.DoctorsOfSections AS s WHERE s.[sectionID] = 2)"