This is a migrated thread and some comments may be shown as answers.

Creating multiple tables on new row commit

3 Answers 59 Views
GridView
This is a migrated thread and some comments may be shown as answers.
None
Top achievements
Rank 1
None asked on 31 Dec 2013, 04:13 PM
I have a grid that is bound to a table in EF. I recently changed the design and I am getting the following exception.

Entities in 'CFETSDBContainer.FREQUENCIES' participate in the 'FREQUENCYFreqPool' relationship. 0 related 'FreqPool' were found. 1 'FreqPool' is expected.

Why it is doing this is obvious, but I don't know HOW to fix it. When the user enters a new row in the data grid and commits it, it needs to create the new FREQ_POOL and FREQ_TYPE entries as well.

FREQ_POOL and FREQ_TYPE are base classes, and so I need to manually set the types of both and set their properties in the code-behind I believe.

How do I do this? I have only done simple databinding. Here is my code.


<DataGrid  AutoGenerateColumns="False" Height="278" HorizontalAlignment="Left" Margin="24,31,0,0" Name="dgIA" VerticalAlignment="Top" Width="520" Loaded="dataGrid1_Loaded" RowEditEnding="dgIA_RowEditEnding" DataContext="{Binding}">
        <DataGrid.Columns>
 
            <DataGridComboBoxColumn DisplayMemberPath="Name" Header="GACC" SelectedValuePath="{Binding Name}" x:Name="cbGACCS" SelectedValueBinding="{Binding ZONE.GACC,Mode=TwoWay}" />           
            <DataGridComboBoxColumn DisplayMemberPath="Name" Header="Zones" SelectedValuePath="{Binding Name}" x:Name="cbZONES" SelectedValueBinding="{Binding ZONE,Mode=TwoWay}" />               
            <DataGridTextColumn Header="Frequency" Binding="{Binding Path=Frequency,Mode=TwoWay}"/>
 
            <DataGridComboBoxColumn Header="Frequency Type" x:Name="cbFT"  SelectedValueBinding="{Binding Path=FrequencyType,Mode=TwoWay}"/>
            <DataGridComboBoxColumn  Header="Owner" x:Name="cbOwner" SelectedValueBinding="{Binding Path=Owner,Mode=TwoWay}" /> 
 
            <DataGridTextColumn Header="Usage Type" Binding="{Binding Path=UsageType,Mode=TwoWay}"/>
            <DataGridTextColumn Header="Comments" Binding="{Binding Path=Comments,Mode=TwoWay}"/>
            <DataGridTextColumn Header="Serial #" Binding="{Binding Path=Serial,Mode=TwoWay}"/>
 
        </DataGrid.Columns>
    </DataGrid>
Code behind:
   private void dgIA_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
    {
        if (!isManualEditCommit)
        {
            isManualEditCommit = true;
 
                DataGrid grid = (DataGrid)sender;
                grid.CommitEdit(DataGridEditingUnit.Row, true);
                ctx.SaveChanges();
 
            isManualEditCommit = false;
        }     
 
    }
}



And here as a screen shot of my EDM that I am referring to.
http://imgbin.org/index.php?page=image&id=16176

How can I achieve this kind of row insert? Thanks.

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 03 Jan 2014, 07:50 AM
Hi Matt,

I might be missing something, but neither of your queries seem related to our controls. If so, my suggestion would be to post them to the related Microsoft forums. In case you have troubles with RadControls, we will assist you further.

Regards,
Maya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
None
Top achievements
Rank 1
answered on 03 Jan 2014, 04:14 PM
Sorry, i was using a telerik data grid but couldn't figure out how to do it so I tried the default one. I was more just curious how to insert CUSTOM row insertion logic using the telerik data grid so I can create my entities manually when the user tries to add a new row. Thanks
0
Hristo
Telerik team
answered on 08 Jan 2014, 12:17 PM
Hello Matt,

Firstly, you would have to enter edit mode which can be done programmatically with BeginInsert(). Secondly, the custom row insertion logic can be created by using the AddingNewDataItem event.
In this event you can initialize the object that has to be added with your custom logic and pass it to the GridViewAddingNewEventArgs.

More information on adding new rows to RadGridView can be found in the following articles in our online documentation: link, link.

Regards,
Hristo
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
None
Top achievements
Rank 1
Answers by
Maya
Telerik team
None
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or