I have a RadGrid that I am converting from using standard SQL datasources to using LINQDatasources. This is a grid that has a two level hyerarchy with a mastertableview and a detailtableview which are defined as follows:
When I was using the SQL datasource automatic Inserts into the DetailTable (FormBatchDS) worked fine. Now that I am using a LINQ datasource the parents MasterKeyField (FormNomId) is not getting passed to the DetailTable properly. From what I see in the debugger (by putting a break point in the generated LINQ insert handler) FormNomId is being passed in as 0 when it should be some non-zero number.
Is there some way to hook the grids insert command to set the proper value for that field before the insert is passed to the LINQ? I figured out how to use the "ItemCommand" method to capture the "PerformInsertCommand" event and then read the parent records MasterKey value:
which gets me the correct MasterKey, but I have not figured out how to update the data being submitted for insert so that the proper value is set when the data is passed to LINQ for the actual DB update.
By the way, if i make the FormNomId field visible and editable in the DetailTableView grid I can manually populate the field the the Insert works just find. Make it read-only and/or not visible and the Insert fails.
Thanks,
Stephen
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" |
AllowSorting="True" DataSourceID="FormulationDS" |
GridLines="None" ShowGroupPanel="True" |
AllowAutomaticInserts="True" AllowAutomaticUpdates="True" |
EnableLinqExpressions="true"> |
<MasterTableView AutoGenerateColumns="False" DataKeyNames="FormNomId" |
CommandItemDisplay="Top" DataSourceID="FormulationDS"> |
.. |
.. |
.. |
<DetailTables> |
<telerik:GridTableView runat="server" CommandItemDisplay="Top" |
DataSourceID="FormBatchDS" AutoGenerateColumns="False" |
DataKeyNames="BatchId" AllowAutomaticInserts="true"> |
<ParentTableRelation> |
<telerik:GridRelationFields |
DetailKeyField="FormNomId" |
MasterKeyField="FormNomId" /> |
</ParentTableRelation> |
.. |
.. |
.. |
Is there some way to hook the grids insert command to set the proper value for that field before the insert is passed to the LINQ? I figured out how to use the "ItemCommand" method to capture the "PerformInsertCommand" event and then read the parent records MasterKey value:
_formNomId = (int)(parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex["FormNomId"]); |
which gets me the correct MasterKey, but I have not figured out how to update the data being submitted for insert so that the proper value is set when the data is passed to LINQ for the actual DB update.
By the way, if i make the FormNomId field visible and editable in the DetailTableView grid I can manually populate the field the the Insert works just find. Make it read-only and/or not visible and the Insert fails.
Thanks,
Stephen