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

Editing Child Entities on Many-to-Many Relationship

9 Answers 193 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Robert Kaucher
Top achievements
Rank 2
Robert Kaucher asked on 30 Mar 2011, 07:05 PM
I am using EF4 and a WCF RIA DomainService. One of my entities represents a "Dealer." There is then a table in the DB called DealerContact, which is represented in my model as an entity of the same name. It has a related table called Contact. Thus allowing us to list multiple contqacts for a single dealer.

Dealer (Class has a DealerCntacts EntityCollection attribute)
 * DealerContacts (each DealerContact has a single Contact attribute)
    * Contact

I have an SL page with Two RadGridViews. The first displays all dealers. The second RadGridView displays the DealerContacts collection of the selected Dealer. I then wired up a DataForm control to the first RGV displaying the dealer and it works flawlessly. What I want to do now is allow a new Contact to be created using a RadDataForm. I cannot seem to get that to work properly. I have attached an image of the UI for better clarity.

When I attempt to insert the new Contact it shows up as all fields blank in the RGV regardless of what I type in the DataForm and the new item is not saved. I receive no errors.

Thanks!

9 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 05 Apr 2011, 10:14 AM
Hello Robert,

Some XAML and/or  code behind would be helpful for me to see what went wrong. Meanwhile I may give a suggestion  - You may handle Edit Ended event of the RadDataForm and inside call the update method of your context.

Since this is a common  question , I am also going to prepare a small online sample application with RadGridView , RadDataForm  and full crud support with RIA services. I am leaving the thread open , so I can later notify you when the sample is ready .

Regards,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Robert Kaucher
Top achievements
Rank 2
answered on 05 Apr 2011, 01:29 PM
EDIT:
Sorry - did not realize what I had done with the code!


Here is my XAML:
<StackPanel x:Name="ContentStackPanel" Style="{StaticResource ContentPanelStyle}">
                <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:Site, CreateList=true}" Height="0" LoadingData="siteDomainDataSource_LoadingData" LoadedData="siteDomainDataSource_LoadedData" Name="siteDomainDataSource" QueryName="GetSitesQuery" Width="0">
                    <riaControls:DomainDataSource.DomainContext>
                        <my:BetaSiteDomainContext />
                    </riaControls:DomainDataSource.DomainContext>
                </riaControls:DomainDataSource>
                <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal">
                        <toolkit:BusyIndicator Name="busySites" IsBusy="True">
                            <telerik:RadGridView  VerticalAlignment="Top"
                                                
                    Background="#8F033F5A" BorderBrush="#B940CAFB"
                    AutoGenerateColumns="False" 
                    Margin="5" Name="radGridViewSites"
                    Width="805"
                    Height="471"
                    telerik:StyleManager.Theme="Transparent" 
                    ItemsSource="{Binding Data, ElementName=siteDomainDataSource}" 
                    CellEditEnded="radGridViewSites_CellEditCompleted">
                                <telerik:RadGridView.Columns>
                                    <telerik:GridViewDataColumn Header="Company Name" DataMemberBinding="{Binding CompanyName}"/>
                                    <telerik:GridViewDataColumn Header="Address 1" DataMemberBinding="{Binding Address1}"/>
                                    <telerik:GridViewDataColumn Header="City" DataMemberBinding="{Binding City}"/>
                                    <telerik:GridViewDataColumn Header="Postal Code" DataMemberBinding="{Binding PostalCD}"/>
                                    <telerik:GridViewDataColumn Header="Country" DataMemberBinding="{Binding CountryCode.CountryName}"/>
                                    <telerik:GridViewDataColumn Header="Phone" DataMemberBinding="{Binding Phone}"/>
                                    <telerik:GridViewDataColumn Header="Email" DataMemberBinding="{Binding Email}"/>
  
                                </telerik:RadGridView.Columns>
                            </telerik:RadGridView>
                        </toolkit:BusyIndicator>
                        <Border Margin="3" >
                            <StackPanel Orientation="Vertical" Background="#8F033F5A" Width="335">
                                <StackPanel.Resources>
                                      
                                    <!--READ ONLY-->
                                    <DataTemplate x:Key="readSiteTemplate">
                                        <StackPanel>
                                            <StackPanel Orientation="Horizontal">
                                                <sdk:Label Margin="5">Edit the selected site:</sdk:Label>
                                            </StackPanel>
  
                                            <Rectangle Height="3" Width="329" Fill="#B940CAFB" />
                                            <Grid Margin="3" HorizontalAlignment="Left" Name="grid1" VerticalAlignment="Top">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto" />
                                                    <ColumnDefinition Width="Auto" />
                                                </Grid.ColumnDefinitions>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                </Grid.RowDefinitions>
                                                <sdk:Label Content="Company Name:" 
                                       Grid.Column="0" Grid.Row="0" 
                                       HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox IsEnabled="False" Grid.Column="1" Grid.Row="0" 
                                     Height="23" HorizontalAlignment="Left" Margin="3" Name="companyNameTextBox" Text="{Binding Path=CompanyName, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
  
                                                <sdk:Label Content="Description:" 
                                       Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox IsEnabled="False"
                                Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="3" Name="descriptionTextBox" Text="{Binding Path=Description, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
                                                <sdk:Label Content="Notes:" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Top" />
                                                <TextBox IsEnabled="False"
                                    TextWrapping="Wrap"
                                Grid.Column="1" Grid.Row="3" Height="69" HorizontalAlignment="Left" Margin="3" Name="notesTextBox" Text="{Binding Path=Notes, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
  
                                                <sdk:Label Content="Address 1:" 
                                       Grid.Column="0" Grid.Row="4" 
                                       HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox Grid.Column="1" Grid.Row="4" IsEnabled="False"
                                     Height="23" HorizontalAlignment="Left" Margin="3" Name="address1TextBox" Text="{Binding Path=Address1, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
                                                <sdk:Label Content="Address 2:" 
                                       Grid.Column="0" Grid.Row="5" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox Grid.Column="1" Grid.Row="5" IsEnabled="False"
                                     Height="23" HorizontalAlignment="Left" Margin="3" Name="address2TextBox" Text="{Binding Path=Address2, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
                                                <sdk:Label Content="Address 3:" 
                                       Grid.Column="0" Grid.Row="6" 
                                       HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox Grid.Column="1" Grid.Row="6" IsEnabled="False"
                                     Height="23" HorizontalAlignment="Left" Margin="3" Name="address3TextBox" Text="{Binding Path=Address3, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
                                                <sdk:Label Content="City:" 
                                       Grid.Column="0" Grid.Row="7" 
                                       HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox IsEnabled="False"
                                Grid.Column="1" Grid.Row="7" 
                                Height="23"
                                HorizontalAlignment="Left" Margin="3" Name="cityTextBox" Text="{Binding Path=City, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
                                                <sdk:Label Content="Postal CD:" 
                                       Grid.Column="0" Grid.Row="8"
                                       HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox IsEnabled="False"
                                Grid.Column="1" Grid.Row="8" 
                                Height="23" HorizontalAlignment="Left" Margin="3" Name="postalCDTextBox" Text="{Binding Path=PostalCD, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
  
                                                <sdk:Label Content="State:" 
                                       Grid.Column="0" Grid.Row="9" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <telerik:RadComboBox IsEnabled="False"
                                Grid.Column="1" Grid.Row="9" 
                                Height="23" HorizontalAlignment="Left" Margin="3" Name="stateTextBox" 
                                ItemsSource="{Binding Data, Source={StaticResource stateProvinceDomainDataSource}, Mode=TwoWay}"
                                SelectedItem="{Binding State, TargetNullValue='XX'}"
                                SelectedValue="{Binding State, Mode=TwoWay}"
                                SelectedValuePath="State"
                                DisplayMemberPath="StateProvName"
                                VerticalAlignment="Center" Width="200" />
  
                                                <sdk:Label Content="Country:" 
                                       Grid.Column="0" Grid.Row="10" 
                                       HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <telerik:RadComboBox IsEnabled="False"
                              Grid.Column="1" Grid.Row="10" 
                              Height="23" 
                              HorizontalAlignment="Left" Margin="3"
                              Name="countryCDComboBox"
                                
                              ItemsSource="{Binding Data, Source={StaticResource countryCodeDomainDataSource}, Mode=TwoWay}" 
                              SelectedItem="{Binding CountryCD}"
                              SelectedValue="{Binding CountryCD, Mode=TwoWay}"
                              SelectedValuePath="CountryCD"
                              DisplayMemberPath="CountryName"
                              VerticalAlignment="Center" Width="200" />
  
  
                                                <sdk:Label Content="Fax:" 
                                       Grid.Column="0" Grid.Row="11" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox IsEnabled="False"
                                Grid.Column="1" Grid.Row="11" Height="23" HorizontalAlignment="Left" Margin="3" Name="faxTextBox" Text="{Binding Path=Fax, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
  
                                                <sdk:Label Content="Phone:" 
                                       Grid.Column="0" Grid.Row="12" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox IsEnabled="False"
                                Grid.Column="1" Grid.Row="12" 
                                Height="23" HorizontalAlignment="Left" Margin="3" Name="phoneTextBox" Text="{Binding Path=Phone, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
  
  
                                                <sdk:Label Content="Web Page:" 
                                       Grid.Column="0" Grid.Row="13" 
                                       HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox IsEnabled="False"
                                Grid.Column="1" Grid.Row="13" 
                                Height="23" HorizontalAlignment="Left" Margin="3" Name="webPageTextBox" Text="{Binding Path=WebPage, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
                                                <sdk:Label Grid.Column="0" Grid.Row="14">Email:</sdk:Label>
                                                <TextBox Text="{Binding Email, Mode=TwoWay}"
                                Grid.Column="1" Grid.Row="14" IsEnabled="False"
                                Height="23" HorizontalAlignment="Left" Margin="3" Name="emailTextBox" VerticalAlignment="Center" Width="200" />
                                            </Grid>
                                        </StackPanel>
                                    </DataTemplate>
                                    <!--READ-->
                                      
                                    <!--EDIT ITEM-->
                                    <DataTemplate x:Key="editSiteTemplate">
                                        <StackPanel>
                                            <StackPanel Orientation="Horizontal">
                                                <sdk:Label Margin="5">Edit the selected site:</sdk:Label>
                                            </StackPanel>
  
                                            <Rectangle Height="3" Width="329" Fill="#B940CAFB" />
                                            <Grid Margin="3" HorizontalAlignment="Left" Name="grid1" VerticalAlignment="Top">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto" />
                                                    <ColumnDefinition Width="Auto" />
                                                </Grid.ColumnDefinitions>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                </Grid.RowDefinitions>
                                                <sdk:Label Content="Company Name:" 
                                       Grid.Column="0" Grid.Row="0" 
                                       HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox Grid.Column="1" Grid.Row="0" 
                                     Height="23" HorizontalAlignment="Left" Margin="3" Name="companyNameTextBox" Text="{Binding Path=CompanyName, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
  
                                                <sdk:Label Content="Description:" 
                                       Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox 
                                Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="3" Name="descriptionTextBox" Text="{Binding Path=Description, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
                                                <sdk:Label Content="Notes:" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Top" />
                                                <TextBox 
                                    TextWrapping="Wrap"
                                Grid.Column="1" Grid.Row="3" Height="69" HorizontalAlignment="Left" Margin="3" Name="notesTextBox" Text="{Binding Path=Notes, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
  
                                                <sdk:Label Content="Address 1:" 
                                       Grid.Column="0" Grid.Row="4" 
                                       HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox Grid.Column="1" Grid.Row="4" 
                                     Height="23" HorizontalAlignment="Left" Margin="3" Name="address1TextBox" Text="{Binding Path=Address1, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
                                                <sdk:Label Content="Address 2:" 
                                       Grid.Column="0" Grid.Row="5" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox Grid.Column="1" Grid.Row="5" 
                                     Height="23" HorizontalAlignment="Left" Margin="3" Name="address2TextBox" Text="{Binding Path=Address2, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
                                                <sdk:Label Content="Address 3:" 
                                       Grid.Column="0" Grid.Row="6" 
                                       HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox Grid.Column="1" Grid.Row="6" 
                                     Height="23" HorizontalAlignment="Left" Margin="3" Name="address3TextBox" Text="{Binding Path=Address3, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
                                                <sdk:Label Content="City:" 
                                       Grid.Column="0" Grid.Row="7" 
                                       HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox 
                                Grid.Column="1" Grid.Row="7" 
                                Height="23"
                                HorizontalAlignment="Left" Margin="3" Name="cityTextBox" Text="{Binding Path=City, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
                                                <sdk:Label Content="Postal CD:" 
                                       Grid.Column="0" Grid.Row="8"
                                       HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox 
                                Grid.Column="1" Grid.Row="8" 
                                Height="23" HorizontalAlignment="Left" Margin="3" Name="postalCDTextBox" Text="{Binding Path=PostalCD, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
  
                                                <sdk:Label Content="State:" 
                                       Grid.Column="0" Grid.Row="9" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <telerik:RadComboBox 
                                Grid.Column="1" Grid.Row="9" 
                                Height="23" HorizontalAlignment="Left" Margin="3" Name="stateTextBox" 
                                ItemsSource="{Binding Data, Source={StaticResource stateProvinceDomainDataSource}, Mode=TwoWay}"
                                SelectedItem="{Binding State, TargetNullValue='XX'}"
                                SelectedValue="{Binding State, Mode=TwoWay}"
                                SelectedValuePath="State"
                                DisplayMemberPath="StateProvName"
                                VerticalAlignment="Center" Width="200" />
  
                                                <sdk:Label Content="Country:" 
                                       Grid.Column="0" Grid.Row="10" 
                                       HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <telerik:RadComboBox 
                              Grid.Column="1" Grid.Row="10" 
                              Height="23" 
                              HorizontalAlignment="Left" Margin="3"
                              Name="countryCDComboBox"
                                
                              ItemsSource="{Binding Data, Source={StaticResource countryCodeDomainDataSource}, Mode=TwoWay}" 
                              SelectedItem="{Binding CountryCD}"
                              SelectedValue="{Binding CountryCD, Mode=TwoWay}"
                              SelectedValuePath="CountryCD"
                              DisplayMemberPath="CountryName"
                              VerticalAlignment="Center" Width="200" />
  
  
                                                <sdk:Label Content="Fax:" 
                                       Grid.Column="0" Grid.Row="11" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox 
                                Grid.Column="1" Grid.Row="11" Height="23" HorizontalAlignment="Left" Margin="3" Name="faxTextBox" Text="{Binding Path=Fax, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
  
                                                <sdk:Label Content="Phone:" 
                                       Grid.Column="0" Grid.Row="12" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox 
                                Grid.Column="1" Grid.Row="12" 
                                Height="23" HorizontalAlignment="Left" Margin="3" Name="phoneTextBox" Text="{Binding Path=Phone, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
  
  
                                                <sdk:Label Content="Web Page:" 
                                       Grid.Column="0" Grid.Row="13" 
                                       HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                                <TextBox 
                                Grid.Column="1" Grid.Row="13" 
                                Height="23" HorizontalAlignment="Left" Margin="3" Name="webPageTextBox" Text="{Binding Path=WebPage, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="200" />
                                                <sdk:Label Grid.Column="0" Grid.Row="14">Email:</sdk:Label>
                                                <TextBox Text="{Binding Email, Mode=TwoWay}"
                                Grid.Column="1" Grid.Row="14" 
                                Height="23" HorizontalAlignment="Left" Margin="3" Name="emailTextBox" VerticalAlignment="Center" Width="200" />
                                            </Grid>
                                        </StackPanel>
                                    </DataTemplate>
                                </StackPanel.Resources>
                                <telerik:RadDataForm AutoGenerateFields="False" 
                                                     ItemsSource="{Binding Data, ElementName=siteDomainDataSource}" EditEnded="siteDataForm_EditEnded" DeletedItem="siteDataForm_DeletedItem" Width="331" 
                                                     x:Name="siteDataForm"
                                                     Background="Transparent"
                                                     EditTemplate="{StaticResource editSiteTemplate}"
                                                     NewItemTemplate="{StaticResource editSiteTemplate}"
                                                     ReadOnlyTemplate="{StaticResource readSiteTemplate}"
                                                     />
                            </StackPanel>
                        </Border>
                    </StackPanel>
                          
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <StackPanel Orientation="Vertical">
                        <sdk:Label>Contacts associated with selected site:</sdk:Label>
                        <toolkit:BusyIndicator IsBusy="True" x:Name="busyContacts">
                            <telerik:RadGridView 
                    AutoGenerateColumns="False" 
                    Margin="5" ItemsSource="{Binding SelectedItem.SiteContacts, ElementName=radGridViewSites}" 
                    telerik:StyleManager.Theme="Transparent" Width="578" Background="#8F033F5A" BorderBrush="#B940CAFB" Height="278" Name="rgv_Contacts">
                                <telerik:RadGridView.Columns>
                                    <telerik:GridViewDataColumn Header="First Name" DataMemberBinding="{Binding Contact.FirstName}"/>
                                    <telerik:GridViewDataColumn Header="Last Name" DataMemberBinding="{Binding Contact.LastName}"/>
                                    <telerik:GridViewDataColumn Header="Phone" DataMemberBinding="{Binding Contact.Phone}"/>
                                    <telerik:GridViewDataColumn Header="Email" DataMemberBinding="{Binding Contact.Email}"/>
  
                                </telerik:RadGridView.Columns>
                            </telerik:RadGridView>
                        </toolkit:BusyIndicator>
                    </StackPanel>
                    <StackPanel Margin="50,0,0,0">
                        <StackPanel.Resources>
                            <!--READ TEMPLATE-->
                            <DataTemplate x:Key="readContactTemplate">
                                <StackPanel Margin="5" Height="275" Background="#8F033F5A" Orientation="Horizontal">
                                    <Image Source="/BetaSiteTracking;component/Images/contacts-blue-icon.png" VerticalAlignment="Top" Height="79" Width="69" />
                                    <Grid HorizontalAlignment="Left" Name="grid2" VerticalAlignment="Top">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
  
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
  
                                        <!--Name Information-->
                                        <sdk:Label Content="Title:" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox IsEnabled="False" Grid.Column="1" Grid.Row="0" Height="23" HorizontalAlignment="Left" Margin="3" Name="titleTextBox" Text="{Binding Path=Contact.Title, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <sdk:Label Content="First Name:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox IsEnabled="False" Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="3" Name="firstNameTextBox" Text="{Binding Path=Contact.FirstName, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
  
                                        <sdk:Label Content="Last Name:" Grid.Column="2" Grid.Row="1" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="3" IsEnabled="False" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="3" Name="lastNameTextBox" Text="{Binding Path=Contact.LastName, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <!--Name-->
                                        <Rectangle Grid.Row="2" Height="3" Width="400" Grid.ColumnSpan="4" Fill="#BF49CBFC" />
                                        <!--Address info-->
                                        <sdk:Label Content="Address 1:" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="1" Grid.Row="3" IsEnabled="False" Height="23" HorizontalAlignment="Left" Margin="3" Name="address1TextBox1" Text="{Binding Path=Contact.Address1, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <sdk:Label Content="Address 2:" Grid.Column="0" Grid.Row="4" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="1" Grid.Row="4" Height="23" IsEnabled="False" HorizontalAlignment="Left" Margin="3" Name="address2TextBox1" Text="{Binding Path=Contact.Address2, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <sdk:Label Content="Address 3:" Grid.Column="0" Grid.Row="5" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="1" Grid.Row="5" Height="23" IsEnabled="False" HorizontalAlignment="Left" Margin="3" Name="address3TextBox1" Text="{Binding Path=Contact.Address3, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <sdk:Label Content="City:" Grid.Column="0" Grid.Row="6" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="1" Grid.Row="6" Height="23" IsEnabled="False" HorizontalAlignment="Left" Margin="3" Name="cityTextBox1" Text="{Binding Path=Contact.City, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <sdk:Label Content="State:" Grid.Column="0" Grid.Row="7" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <telerik:RadComboBox Height="23" Grid.Column="1" Grid.Row="7" Margin="3" IsEnabled="False"
                                                      ItemsSource="{Binding Data, Source={StaticResource stateDomainDataSource2}}"
                                                      SelectedValue="{Binding Path=Contact.State, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue='XX'}"
                                                      SelectedValuePath="State"
                                                      DisplayMemberPath="StateProvName"/>
                                        <!--<telerik:RadComboBox Grid.Column="1" Grid.Row="7" Height="23" HorizontalAlignment="Left" Margin="3" Name="stateComboBox1"
                                          SelectedItem="{Binding State, TargetNullValue='XX'}"
                                          ItemsSource="{Binding Data, Source={StaticResource stateDomainDataSource2}}"
                                          DisplayMemberPath="StateProvName"
                                          SelectedValue="{Binding Path=Contact.State, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue='XX'}"
                                          SelectedValuePath="State"
                                          VerticalAlignment="Center" Width="120" />-->
                                        <sdk:Label Content="Postal CD:" Grid.Column="0" Grid.Row="8" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="1" Grid.Row="8" Height="23" HorizontalAlignment="Left" Margin="3" IsEnabled="False" Name="postalCDTextBox1" Text="{Binding Path=Contact.PostalCD, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
  
                                        <sdk:Label Content="Country:" Grid.Column="0" Grid.Row="9" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <telerik:RadComboBox IsEnabled="False"
                                    Grid.Column="1" Grid.Row="9" Height="23" HorizontalAlignment="Left" Margin="3" Name="contactCountryCDComboBox" 
                                    DisplayMemberPath="CountryName"
                                    ItemsSource="{Binding Data, Source={StaticResource countryCodeDomainDataSource2}}"
                                    SelectedValuePath="CountryCD"
                                    SelectedValue="{Binding Path=Contact.CountryCD, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" 
                                    VerticalAlignment="Center" Width="120" />
                                        <!--Address-->
                                        <!--Contact Information-->
                                        <sdk:Label Content="Email:" Grid.Column="2" Grid.Row="3" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="3" Grid.Row="3" IsEnabled="False" Height="23" HorizontalAlignment="Left" Margin="3" Name="emailTextBox1" Text="{Binding Path=Contact.Email, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <sdk:Label Content="Fax:" Grid.Column="2" Grid.Row="4" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="3" Grid.Row="4" Height="23" IsEnabled="False" HorizontalAlignment="Left" Margin="3" Name="faxTextBox1" Text="{Binding Path=Contact.Fax, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
  
  
                                        <sdk:Label Content="Mobile:" Grid.Column="2" Grid.Row="5" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="3" Grid.Row="5" Height="23" HorizontalAlignment="Left" Margin="3" Name="mobileTextBox" Text="{Binding Path=Contact.Mobile, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <sdk:Label Content="Phone:" Grid.Column="2" Grid.Row="6" IsEnabled="False" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="3" Grid.Row="6" Height="23" HorizontalAlignment="Left" Margin="3" Name="phoneTextBox1" Text="{Binding Path=Contact.Phone, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" IsEnabled="False" Width="120" />
  
  
  
                                    </Grid>
                                </StackPanel>
                            </DataTemplate>
                              
                            <!--EDIT TEMPLATE-->
                            <DataTemplate x:Key="editContactTemplate">
                                <StackPanel Margin="5" Height="275" Background="#8F033F5A" Orientation="Horizontal">
                                    <Image Source="/BetaSiteTracking;component/Images/contacts-blue-icon.png" VerticalAlignment="Top" Height="79" Width="69" />
                                    <Grid HorizontalAlignment="Left" Name="grid2" VerticalAlignment="Top">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
  
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
  
                                        <!--Name Information-->
                                        <sdk:Label Content="Title:" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="1" Grid.Row="0" Height="23" HorizontalAlignment="Left" Margin="3" Name="titleTextBox" Text="{Binding Path=Contact.Title, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <sdk:Label Content="First Name:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="3" Name="firstNameTextBox" Text="{Binding Path=Contact.FirstName, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
  
                                        <sdk:Label Content="Last Name:" Grid.Column="2" Grid.Row="1" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="3" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="3" Name="lastNameTextBox" Text="{Binding Path=Contact.LastName, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <!--Name-->
                                        <Rectangle Grid.Row="2" Height="3" Width="400" Grid.ColumnSpan="4" Fill="#BF49CBFC" />
                                        <!--Address info-->
                                        <sdk:Label Content="Address 1:" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="1" Grid.Row="3" Height="23" HorizontalAlignment="Left" Margin="3" Name="address1TextBox1" Text="{Binding Path=Contact.Address1, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <sdk:Label Content="Address 2:" Grid.Column="0" Grid.Row="4" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="1" Grid.Row="4" Height="23" HorizontalAlignment="Left" Margin="3" Name="address2TextBox1" Text="{Binding Path=Contact.Address2, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <sdk:Label Content="Address 3:" Grid.Column="0" Grid.Row="5" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="1" Grid.Row="5" Height="23" HorizontalAlignment="Left" Margin="3" Name="address3TextBox1" Text="{Binding Path=Contact.Address3, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <sdk:Label Content="City:" Grid.Column="0" Grid.Row="6" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="1" Grid.Row="6" Height="23" HorizontalAlignment="Left" Margin="3" Name="cityTextBox1" Text="{Binding Path=Contact.City, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <sdk:Label Content="State:" Grid.Column="0" Grid.Row="7" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <telerik:RadComboBox Height="23" Grid.Column="1" Grid.Row="7" Margin="3"
                                                      ItemsSource="{Binding Data, Source={StaticResource stateDomainDataSource2}}"
                                                      SelectedValue="{Binding Path=Contact.State, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue='XX'}"
                                                      SelectedValuePath="State"
                                                      DisplayMemberPath="StateProvName"/>
                                        <!--<telerik:RadComboBox Grid.Column="1" Grid.Row="7" Height="23" HorizontalAlignment="Left" Margin="3" Name="stateComboBox1"
                                          SelectedItem="{Binding State, TargetNullValue='XX'}"
                                          ItemsSource="{Binding Data, Source={StaticResource stateDomainDataSource2}}"
                                          DisplayMemberPath="StateProvName"
                                          SelectedValue="{Binding Path=Contact.State, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue='XX'}"
                                          SelectedValuePath="State"
                                          VerticalAlignment="Center" Width="120" />-->
                                        <sdk:Label Content="Postal CD:" Grid.Column="0" Grid.Row="8" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="1" Grid.Row="8" Height="23" HorizontalAlignment="Left" Margin="3" Name="postalCDTextBox1" Text="{Binding Path=Contact.PostalCD, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
  
                                        <sdk:Label Content="Country:" Grid.Column="0" Grid.Row="9" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <telerik:RadComboBox 
                                    Grid.Column="1" Grid.Row="9" Height="23" HorizontalAlignment="Left" Margin="3" Name="contactCountryCDComboBox" 
                                    DisplayMemberPath="CountryName"
                                    ItemsSource="{Binding Data, Source={StaticResource countryCodeDomainDataSource2}}"
                                    SelectedValuePath="CountryCD"
                                    SelectedValue="{Binding Path=Contact.CountryCD, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" 
                                    VerticalAlignment="Center" Width="120" />
                                        <!--Address-->
                                        <!--Contact Information-->
                                        <sdk:Label Content="Email:" Grid.Column="2" Grid.Row="3" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="3" Grid.Row="3" Height="23" HorizontalAlignment="Left" Margin="3" Name="emailTextBox1" Text="{Binding Path=Contact.Email, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <sdk:Label Content="Fax:" Grid.Column="2" Grid.Row="4" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="3" Grid.Row="4" Height="23" HorizontalAlignment="Left" Margin="3" Name="faxTextBox1" Text="{Binding Path=Contact.Fax, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
  
  
                                        <sdk:Label Content="Mobile:" Grid.Column="2" Grid.Row="5" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="3" Grid.Row="5" Height="23" HorizontalAlignment="Left" Margin="3" Name="mobileTextBox" Text="{Binding Path=Contact.Mobile, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
                                        <sdk:Label Content="Phone:" Grid.Column="2" Grid.Row="6" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                                        <TextBox Grid.Column="3" Grid.Row="6" Height="23" HorizontalAlignment="Left" Margin="3" Name="phoneTextBox1" Text="{Binding Path=Contact.Phone, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}" VerticalAlignment="Center" Width="120" />
  
  
  
                                    </Grid>
                                </StackPanel>
                            </DataTemplate>
                        </StackPanel.Resources>
                        <sdk:Label FontWeight="Bold">Information for selected contact:</sdk:Label>
                        <Rectangle Height="3" Margin="3" Width="525" Fill="#BB54D6FD" />
                        <telerik:RadDataForm x:Name="siteContactForm" Width="525" Background="Transparent" EditEnded="siteContactForm_EditEnded" DeletedItem="siteContactForm_DeletedItem" AutoGenerateFields="False"
                                             ReadOnlyTemplate="{StaticResource readContactTemplate}"
                                             EditTemplate="{StaticResource editContactTemplate}"
                                             NewItemTemplate="{StaticResource editContactTemplate}"
                                             ItemsSource="{Binding Source={StaticResource siteSiteContactsViewSource}}"
                                             />
                    </StackPanel>
  
                    </StackPanel>
                </StackPanel>
             
private void siteDataForm_EditEnded(object sender, Telerik.Windows.Controls.Data.DataForm.EditEndedEventArgs e)
{
    siteDomainDataSource.SubmitChanges();
}
private void siteDataForm_DeletedItem(object sender, Telerik.Windows.Controls.Data.DataForm.ItemDeletedEventArgs e)
{
    ConfirmDelete confWin = new ConfirmDelete();
    confWin.Closed += new EventHandler(confWin_Closed);
    confWin.Show();
}
private void siteContactForm_EditEnded(object sender, Telerik.Windows.Controls.Data.DataForm.EditEndedEventArgs e)
{
    siteDomainDataSource.SubmitChanges();
}
private void siteContactForm_DeletedItem(object sender, Telerik.Windows.Controls.Data.DataForm.ItemDeletedEventArgs e)
{
    MessageBox.Show("Not Yet Implemented.");
}

 

0
Ivan Ivanov
Telerik team
answered on 08 Apr 2011, 10:04 AM
Hello Robert,

I have prepared a CRUD RIA services example, utilizing RadDataForm, RadGridView and RadDomainDataSource. Please, refer to it and do not hesitate to contact us if you have any further inquiries.

Greetings,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Robert Kaucher
Top achievements
Rank 2
answered on 08 Apr 2011, 01:34 PM
Ivan, thanks for the reply but your example is too basic to really help me. As I stated in my initial message the issue is not simple CRUD on the top level object. That is very easy to do and understand with the DataForm (which I have fallen in love w/ BTW - you guys rock!). What I am trying to do is insert at the 3rd level of the main object in the DomainDataSource. So again, I have a DomainDataSource that contains the dealer objects. The Dealer entities have a navigation property called DealerContacts (a bridge table in the database), each of which has a navigation property called Contact. I have included an ERD of the three tables. I can CRUD all day long on the Dealer entities. I can update the Contacts on this page as well, but I don't understand how to Create a new contact in this exact situation where the DomainDataSource has the dealer at the top level.

Basically I have said I need to know how to get from point A to point C. I know how to get to point A. I don't know how to get to point C from point A. And you have handed me a map on how to get to point A.
0
Robert Kaucher
Top achievements
Rank 2
answered on 08 Apr 2011, 02:01 PM
Here are the metadata classes for the DS:

[MetadataTypeAttribute(typeof(Dealer.DealerMetadata))] 
    public partial class Dealer 
    
   
        internal sealed class DealerMetadata 
        
            private DealerMetadata() 
            
            
   
            public string Address1 { get; set; } 
   
            public string Address2 { get; set; } 
   
            public string Address3 { get; set; } 
   
            public string BetaSupportLevel { get; set; } 
   
            public string City { get; set; } 
   
            public string CompanyName { get; set; } 
   
            [Include] 
            public EntityCollection<DealerContact> DealerContacts { get; set; } 
   
            public int DealerID { get; set; } 
   
            public string Email { get; set; } 
   
            public string Fax { get; set; } 
   
            public string Notes { get; set; } 
   
            public string Phone { get; set; } 
   
            public string PostalCD { get; set; } 
            [Include] 
            public EntityCollection<SiteDealer> SiteDealers { get; set; } 
   
            public string State { get; set; } 
   
            public State_Province State_Province { get; set; } 
            [Exclude] 
            public byte[] VersionColumn { get; set; } 
   
            public string WebPage { get; set; } 
        
    }
      
    [MetadataTypeAttribute(typeof(DealerContact.DealerContactMetadata))] 
    public partial class DealerContact 
    
   
        internal sealed class DealerContactMetadata 
        
   
            private DealerContactMetadata() 
            
            
            [Include] 
            public Contact Contact { get; set; } 
   
            public int ContactID { get; set; } 
            [Include] 
            public Dealer Dealer { get; set; } 
   
            public int DealerID { get; set; } 
            [Exclude] 
            public byte[] VersionColumn{ get; set; } 
        
    }
      
    [MetadataTypeAttribute(typeof(Contact.ContactMetadata))] 
    public partial class Contact 
    
   
        internal sealed class ContactMetadata 
        
   
            private ContactMetadata() 
            
            
   
            public string Address1 { get; set; } 
   
            public string Address2 { get; set; } 
   
            public string Address3 { get; set; } 
   
            public string City { get; set; } 
   
            public int ContactID { get; set; } 
   
            public string CountryCD { get; set; } 
            [Include] 
            public CountryCode CountryCode { get; set; } 
   
            [Include] 
            public EntityCollection<DealerContact> DealerContacts { get; set; } 
   
            public string Email { get; set; } 
   
            public string Fax { get; set; } 
   
            public string FirstName { get; set; } 
   
            public string LastName { get; set; } 
   
            public string Mobile { get; set; } 
   
            public string Phone { get; set; } 
   
            public string PostalCD { get; set; } 
            [Include] 
            public EntityCollection<SiteContact> SiteContacts { get; set; } 
   
            public string State { get; set; } 
   
            [Include] 
            public State_Province State_Province { get; set; } 
   
            public string Title { get; set; } 
            [Exclude] 
            public byte[] VersionColumn { get; set; } 
        
    }
0
Ivan Ivanov
Telerik team
answered on 14 Apr 2011, 11:59 AM
Hello Robert,

First of all, excuse me for the late answer. Since your question is more related to entity framework and RIA services in general than to the functionality of our controls, I fear that I cannot give you a complete solution to your business problem.  Nevertheless I created an example for you, utilizing tables from Northwind that are in the same relation as yours. Please, refer to it and inform us if this setting is close to your requirements.    

All the best,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jon Shipman
Top achievements
Rank 1
answered on 14 Jan 2012, 12:50 AM
Hello Ivan,

Thank you so much for the example named SilverlightApplication6.  It's been very helpful!

In the code-generated file, SilverlightApplication6.Web.g.cs, the following methods are being generated.  I'm trying to develop a similar project, but the EntityQuery<> methods aren't being generated.  In your example, in the MainPage.xaml.cs, you use one of these queries (GetRelatedProductsQuery). Do you know what's required to get these methods generated?

public EntityQuery<Order_Detail> GetOrder_DetailsQuery()
{
    this.ValidateMethod("GetOrder_DetailsQuery", null);
    return base.CreateQuery<Order_Detail>("GetOrder_Details", null, false, true);
}
 
public EntityQuery<Order> GetOrdersQuery()
{
    this.ValidateMethod("GetOrdersQuery", null);
    return base.CreateQuery<Order>("GetOrders", null, false, true);
}
 
public EntityQuery<Product> GetProductsQuery()
{
    this.ValidateMethod("GetProductsQuery", null);
    return base.CreateQuery<Product>("GetProducts", null, false, true);
}
         
public EntityQuery<Product> GetRelatedProductsQuery(int pK)
{
    Dictionary<string, object> parameters = new Dictionary<string, object>();
    parameters.Add("pK", pK);
    this.ValidateMethod("GetRelatedProductsQuery", parameters);
    return base.CreateQuery<Product>("GetRelatedProducts", parameters, false, true);
}

0
Ivan Ivanov
Telerik team
answered on 18 Jan 2012, 02:39 PM
Hello Jon,

Have you referenced the respective entities properly, while generating you domain service?

All the best,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Jon Shipman
Top achievements
Rank 1
answered on 26 Jan 2012, 05:06 PM
That may have been it.  I decided to go through the steps of recreating the Entity Model, and the Domain Service, and referencing everything, and the EntityQuery's showed up as expected this time.  So I can't say for certain, but the reference may have been what I was missing.

Thanks for your suggestion!
Tags
DataForm
Asked by
Robert Kaucher
Top achievements
Rank 2
Answers by
Pavel Pavlov
Telerik team
Robert Kaucher
Top achievements
Rank 2
Ivan Ivanov
Telerik team
Jon Shipman
Top achievements
Rank 1
Share this question
or