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

RadComboBox In Dataform

1 Answer 167 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Kayvan Karim
Top achievements
Rank 1
Kayvan Karim asked on 26 Nov 2009, 07:31 PM

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;  
            }  
       

1 Answer, 1 is accepted

Sort by
0
Teodor
Telerik team
answered on 01 Dec 2009, 10:21 AM
Hi Kayvan Karim,

Thank you for contacting us!

Using the code fragments we were not able to find out why you observe this behaviour. Generally, there might be several reasons for that like:
  • data not committed to the database
  • some binding issues

In this relation, could you please provide us with at least a part of your project, so that we can run it locally and manage to reproduce the issue.

Thank you in advance for your assistance.

Greetings,
Teodor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox
Asked by
Kayvan Karim
Top achievements
Rank 1
Answers by
Teodor
Telerik team
Share this question
or