Hi
I’m using a RadGridView and DataForm. I need some ComboBox in my DataFrom.
GridView is Binded to a Table Called Programs. Programs table has a Filed Called ProgramTypeID which is a forgin Key to a table called “ProgramsTypes”. Inside the” ProgramTypes” Table I have PTypeID as Int and ProgramType as String. I need to have a Drop Down in my Dataform so the user can select an Item from the list in the Edit mode.
Problem:
Everything is working OK except when I change the selectedItem in the gridview whatever in ProgramTypeID becomes Null. But if I change the value in comboBox inside my Dataform the correct value will be in the Datagrid. But if again I return to the same record It becomes null.
I'm using a DomainDataSource called SpeaxDTS as my DomainDataSource
Here is my code:
<telerikGridView:RadGridView x:Name="DtgTelerik" AutoGenerateColumns="True" ItemsSource="{Binding ElementName=SpeaxDTS,Path=Data}" > |
<dataFormToolkit:DataForm CommandButtonsVisibility="Edit,Commit,Cancel" |
x:Name="ProgramDetail" |
Header="Program Information" |
AutoGenerateFields="False" |
AutoEdit="False" |
BorderThickness="0" |
Margin="0,10,0,0" |
ContentLoaded="ProgramDetail_ContentLoaded" |
CurrentItem="{Binding ElementName=DtgTelerik,Path=SelectedItem}" |
> |
<dataFormToolkit:DataForm.EditTemplate> |
<DataTemplate> |
<StackPanel> |
<dataFormToolkit:DataField Label="Program Name"> |
<TextBox Text="{Binding ProgramName,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnExceptions=True}" /> |
</dataFormToolkit:DataField> |
<dataFormToolkit:DataField Label="Genre"> |
<TextBox Text="{Binding Genre,Mode=TwoWay}" /> |
</dataFormToolkit:DataField> |
<dataFormToolkit:DataField Label="No. of Eposode"> |
<TextBox Text="{Binding NoOfEpisode, Mode=TwoWay}" /> |
</dataFormToolkit:DataField> |
<dataFormToolkit:DataField Label="Running Time"> |
<TextBox Text="{Binding RunnungTime, Mode=TwoWay}" /> |
</dataFormToolkit:DataField> |
<dataFormToolkit:DataField Label="Dubbing"> |
<TextBox Text="{Binding Dubbing, Mode=TwoWay}" /> |
</dataFormToolkit:DataField> |
<dataFormToolkit:DataField Label="Program Type" > |
<TControl:RadComboBox x:Name="DrpProgramType" |
DisplayMemberPath="ProgramType" |
SelectedValuePath="PTypeID" |
SelectedValue="{Binding ProgramTypeID ,Mode=TwoWay}" |
IsReadOnly="True" |
> |
</TControl:RadComboBox> |
</dataFormToolkit:DataField> |
<dataFormToolkit:DataField Label="Season"> |
<TextBox Text="{Binding Season, Mode=TwoWay}" /> |
</dataFormToolkit:DataField> |
<dataFormToolkit:DataField Label="Synopsis"> |
<TextBox TextWrapping="Wrap" Text="{Binding Synopsis, Mode=TwoWay}" Height="200" /> |
</dataFormToolkit:DataField> |
</StackPanel> |
</DataTemplate> |
</dataFormToolkit:DataForm.EditTemplate> |
private void ProgramDetail_ContentLoaded(object sender, DataFormContentLoadEventArgs e) |
{ |
SpeaxDomainContext dts = new SpeaxDomainContext(); |
dts.Load(dts.GetProgramTypesQuery()); |
RadComboBox combo = (RadComboBox)ProgramDetail.FindNameInContent("DrpProgramType"); |
combo.ItemsSource = dts.ProgramTypes; |
if (e.Mode == DataFormMode.ReadOnly) |
{ |
combo.IsEnabled = false; |
} |
else |
{ |
combo.IsEnabled = true; |
} |