Context:
With a RadGrid, you can have build-in automatic CRUD operation. But those operation seems to be possible only on the source/father table.
<asp:LinqDataSource ID="myLinqDataSource" runat="server"
ContextTypeName="ExempleDataContext" TableName="Order"/>
<telerik:RadGrid ID="myRadGrid" runat="server" DataSourceID="myLinqDataSource">
<MasterTableView .../>
</telerik:RadGrid>
While will be able to display property of Parent or Child:
<telerik:GridBoundColumn DataField="CustomerId" HeaderText="CustomerId"
SortExpression="CustomerId" UniqueName="CustomerId"/>
<telerik:GridBoundColumn DataField="Product.Name" HeaderText="Product.Name"
SortExpression="Product.Name" UniqueName="Product.Name" />
And bind them in your EditForm:
Customer Id :
<asp:TextBox ID="tb_CustomerId" runat="server"
Text='<%#Bind("CustomerId")%>' AutoPostBack="false" />
Product Name:
<asp:TextBox ID="tb_Product_Name" runat="server"
Text='<%#Bind("Product.Name")%>' AutoPostBack="false" />
But only the "Father field" (here CustomerId
) get update.
When Product.Name
is ignored and do not throw any error.
Exemple Dbml Schema:
What I tryed:
- Adding Child Primary key to the Grid
DataKeyNames
. - Adding
RetrieveDataTypeFromFirstItem="true"
, toMasterTableView
trying to force him to get the type off the sub Item. - And classical telerik vodoo, ending using manual insert and ItemCommand event.
Nb:
- Inplace and automated Update works. Only the Templated Form failed to bind.
I'm not familiar with AJAX (working on C# version of telerik), but AFAIK, you can't use such syntax as "Product.Name". Bindings refers only to fields inside class, in your case it is something like
Which means, you can refer only directly to class properties. If you populate your container with data type of i.e. Customer, you can only make binding to Id and Name property.
To achieve what you want to do, you can create custom DTO class, for example
Then create collection of those objects and populate it with data from DB, and manipulate the data from your container.
If you want to stick to Build in CRUD option, you need to decide what type of object you want to edit inside of your container - Either Order, Customer or Product.
Since you have quite simple relations betweens your tables, which are one-to-zero-or-one, I'd go with creating DTO class, to easy manage data.
Best luck