I have the following statement tested on the sql server:
select AsignaturaNombre from Asignatura where CodigoAsignatura=(SELECT [idMateria] FROM [Permisos] WHERE ([idProfesor] = 19398676) union SELECT [idMateria] FROM [Permisos] WHERE ([idAlumno] = 19398676))
But at the moment of passing sentence to sqldatasource
in the following way:
<h5>
<asp:Label ID="Label4" runat="server" Text="Selecione la materia "></asp:Label>
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource1" DataTextField="idMateria" DataValueField="idMateria">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:UMAConnectionString %>" SelectCommand="select AsignaturaNombre from Asignatura where CodigoAsignatura=(SELECT [idMateria] FROM [Permisos] WHERE ([idProfesor] = @idAlumno) union SELECT [idMateria] FROM [Permisos] WHERE ([idAlumno] = @idAlumno))">
<SelectParameters>
<asp:SessionParameter Name="idAlumno" SessionField="Codigo" Type="Double" />
</SelectParameters>
</asp:SqlDataSource>
</h5>
But he tells me he does not recognize the instruction and jumps an exception:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'idMateria'.
How can I place that sentence?