Just converted a website using Dynamic Data to .NET 4.0. The basic scenario is that LinqDataSource is querying a Ticket, which has several associations (i.e. 'Contact') to other tables in the database. Now when the page loads and the DynamicField tries to bind to some of those associations I get the following error:
The table 'Tickets' does not have a column named 'Contact'.
If I debug and break in the OnSelected event for the LinqDataSource I can clearly see that Contact is there, and even view it's data in the debugger. So I know it's there...
Also there are some associations which DO work, and are set up the same way as the ones which are not working. So I have no idea what the difference is, or why it isn't working for some.
For reference here is the LinqDataSource declaration:
<asp:LinqDataSource ID="ldsTicket" runat="server" OnSelected="ldsTicket_Selected"
ContextTypeName="ClearviewInterface.ESLinqDataContext" OnUpdating="ldsTicket_Updating"
OnInserting="ldsTicket_Inserting" EnableInsert="True" EnableUpdate="True"
TableName="Tickets"
Where="ID == Convert.ToInt32(@ID) &&
HeaderDocType == @docType &&
(Convert.ToInt32(@ccID) == 2
|| Company.ID == Convert.ToInt32(@ccID)
|| Company.Masters.Any(MasterID == Convert.ToInt32(@ccID)))" >
<WhereParameters>
<asp:ControlParameter ControlID="txtTicketID" Name="ID" PropertyName="Text" Type="Int32" />
<asp:ControlParameter ControlID="hfCurrentCompanyID" Name="ccID" PropertyName="Value" Type="Int32" />
<asp:Parameter DefaultValue="CLH" Type="String" Name="docType" />
</WhereParameters>
</asp:LinqDataSource>
And here is the DynamicData field declarations in the ListView:
Doesn't Work:
<asp:DynamicControl ID="dcContact" Mode="ReadOnly" DataField="Contact" runat="server" />
Works:
EDIT:
I've done some more testing and am finding that I can use Eval() to get the data from the data source:
<%# Eval("Contact") %> <%# Eval("Contact.FirstName") %>
But the DynamicControl will not recognize "Contact" or "Contact.FirstName" as a DataField, so I'm still stuck. I think something may have been updated with DynamicControl in .NET 4, rather than the LinqDataSource as I originally thought.
Again though, I'm not seeing a difference between "Problem" and "Contact" however. Both are declared with a UIHint to a custom FieldTemplate... both have metadata classes though the Contact MD class has more complexity. Doesn't seem like that should matter though right?
Anyone got a clue what could have been changed in DynamicControl?