RadComboBox In Dataform

2 posts, 0 answers
  1. Kayvan Karim
    Kayvan Karim avatar
    1 posts
    Member since:
    Oct 2009

    Posted 26 Nov 2009 Link to this post

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

  2. Teodor
    Admin
    Teodor avatar
    501 posts

    Posted 01 Dec 2009 Link to this post

    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.
Back to Top