I have a Hierarchiel radgrid of 2levels. My first level is populated by LinqDataSourceTargetCategory.
2nd level is populated by LinqDataSourceTargetCategoryInfo.
Level 1 data is from tblTargetCategory.
Level 2 data is from tblTargetCategoryInfo.
Where="TargetCategoryId == @TargetCategoryId">
<asp:Parameter Name="TargetCategoryId" Type="Int32" />
So it knows which record in level 2 grid belong to which record from level1. I also have:
<MasterTableView DataKeyNames="TargetCategoryId" DataSourceID="LinqDataSourceTargetCategory"
<telerik:GridRelationFields DetailKeyField="TargetCategoryId" MasterKeyField="TargetCategoryId" />
tblTargetCategoryInfo has a foreign key TargetCategoryId which comes from tblTargetCategoryId(is primarykey).
I've done this so that my radgrid can load correctly which is does. It loads the 2nd level and associates the records according to TargetCategoryId.
On level one i can INSERT UPDATE DELETE fine using:
But here is the problem. On my 2nd level the data loads correctly but when i want to do an INSERT it says:
"INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_tblTargetCategoryInfo_tblTargetCategory'. The conflict occurred in database 'spe', table
'tblTargetCategory', column 'TargetCategoryId'.
The statement has been terminated."
So i turned off "Enforce foreign key constraint rule" to see what value was been parsed into TargetCategoryId, i noticed it was 0. Obviously causing the error.
TargetCategoryId should be equal to the record which i'm working with, which is on level 1.
So if i'd have record x on level 1 with TargetCategoryId = 1,
then i expand and add a new item y. When i insert i want it to automatically know that i'm adding it to with TargetCategoryId = 1 which is x.
I'm using LINQ datasources.
Sorry for the long post but rather i give you all the information you need to help me. Hope it was a clear description of the problem.
I went to http://demos.telerik.com/aspnet/prometheus/Grid/Examples/DataEditing/ThreeLevel/DefaultCS.aspx and look at the ASPX. It's a custom type of Datasource.. How can i do that INSERT normally? Somehow my DELETE and UPDATE work fine.