I'm wondering if it's possible to use the ForignKey template on a DynamicField in a standard data bound GridView in an non Dynamic Data website.
I tried using the Order Details table from Northwind. I get other dynamic data fields to work (integer, date time), but when I try to use the ForeignKey UIHint, I see this error: 'Order' is not a foreign key column and cannot be used here.
I imported all of the Field Templates from a dynamic data project
Should I expect that this should work and am I just doing something wrong? Or does this not work outside of an actual Dynamic Data website?
No, Dynamic Data Controls can be only used in Dynamic Data website. If you insist using Foreign Key, I think you can use nested GridView or something related to that to show One-To-Many:
devouree
Member
2 Points
2 Posts
Dynamic data on existing gridview and the ForeignKey template
Nov 28, 2012 10:21 PM|LINK
I'm wondering if it's possible to use the ForignKey template on a DynamicField in a standard data bound GridView in an non Dynamic Data website.
I tried using the Order Details table from Northwind. I get other dynamic data fields to work (integer, date time), but when I try to use the ForeignKey UIHint, I see this error: 'Order' is not a foreign key column and cannot be used here.
I imported all of the Field Templates from a dynamic data project
Should I expect that this should work and am I just doing something wrong? Or does this not work outside of an actual Dynamic Data website?
I'm using .NET 4.5, EF 5.0, IIS Express.
Here's my code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="OrderID,ProductID" DataSourceID="EntityDataSource1"> <Columns> <asp:DynamicField DataField="Order" HeaderText="Order" UIHint="ForeignKey" /> </Columns> </asp:GridView> <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=NorthwindEntities" DefaultContainerName="NorthwindEntities" EntitySetName="Order_Details" Include="Order"/>Thanks!
sjnaughton
All-Star
27330 Points
5459 Posts
MVP
Re: Dynamic data on existing gridview and the ForeignKey template
Nov 28, 2012 11:08 PM|LINK
Hi devouree, this is not supported sorry :(
Always seeking an elegant solution.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Dynamic data on existing gridview and the ForeignKey template
Nov 29, 2012 07:01 AM|LINK
No, Dynamic Data Controls can be only used in Dynamic Data website. If you insist using Foreign Key, I think you can use nested GridView or something related to that to show One-To-Many:
http://msdn.microsoft.com/en-us/library/aa992038(v=vs.80).aspx
devouree
Member
2 Points
2 Posts
Re: Dynamic data on existing gridview and the ForeignKey template
Nov 29, 2012 02:10 PM|LINK
Thank you!