Reputation: 2734
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.
DataKeyNames
.RetrieveDataTypeFromFirstItem="true"
, to MasterTableView
trying to force him to get the type off the sub Item.Upvotes: -1
Views: 82
Reputation: 202
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
class Product()
{
public int Id
public string Name
}
class Customer()
{
public int Id
public string Name
}
class Order()
{
public int Id
public int CustomerId
public int ProductId
}
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
class FullDataObject()
{
public int ProductId
public string ProductName
public int CustomerId
public string CustomerName
public int OrderId
}
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
Upvotes: 0