Data doesn't show in the dataform

6 posts, 2 answers
  1. Kamal Mostofi
    Kamal Mostofi avatar
    56 posts
    Member since:
    Jan 2010

    Posted 29 Mar 2011 Link to this post

    Hi,

    I created a page to find out more about telerik dataform. Below is the code
    <telerik:RadDomainDataSource x:Name="dsbijslogans" QueryName="GetSlogans"  AutoLoad="True" >
               <telerik:RadDomainDataSource.DataContext>
                   <ds:SloganServices></ds:SloganServices>
               </telerik:RadDomainDataSource.DataContext>
           </telerik:RadDomainDataSource>
           <Border x:Name="ContentBorder"  Style="{StaticResource ContentBorderStyle}">
               <telerik:RadDataForm telerik:Theming.Theme="Office_Blue" AutoGenerateFields="False" ItemsSource="{Binding dsbijslogans}" Background="Transparent" Header="Home Page Slogans" Margin="50"  >
                   <telerik:RadDataForm.ReadOnlyTemplate>
                       <DataTemplate>
    <telerik:DataFormDataField DataMemberBinding="{Binding slogans, Mode=TwoWay}" Label="Slogans" Foreground="SlateGray"></telerik:DataFormDataField>
                       </DataTemplate>
                   </telerik:RadDataForm.ReadOnlyTemplate>
               </telerik:RadDataForm>
           </Border>

    When I run the application, the form is blank. If I set AutoGenerateFields to true and remove ReadOnlyTemplate, the form is still blank. The data source query is fine.
    Have I missing anything in my xamle code?
    Do I have to load the datasource in the Load Page in code behind?

    Thanks for your help.
    Kam
  2. Answer
    David Ocasio
    David Ocasio avatar
    147 posts
    Member since:
    Nov 2009

    Posted 29 Mar 2011 Link to this post

    It seems to me that your Itemssource is not corectly bound

    when you are binding to another element in the page you need to us "elementname="
    like so:

    ItemsSource="{Binding DataView, ElementName=dsbijslogans}"

    thanks
    dco
  3. DevCraft banner
  4. Kamal Mostofi
    Kamal Mostofi avatar
    56 posts
    Member since:
    Jan 2010

    Posted 30 Mar 2011 Link to this post

    Hello dco,

    thanks for your reply.
    I changed telerik domain datasource with ria domain datasource, and it worked. I don't know what i missed in telerik domain data source that it didn't run.

    <Border x:Name="ContentBorder"  Style="{StaticResource ContentBorderStyle}">
      
                <telerik:RadDataForm telerik:Theming.Theme="Office_Blue" AutoGenerateFields="False" ItemsSource="{Binding Data, ElementName=sloganDomainDataSource}" Background="Transparent" Header="Home Page Slogans" Margin="50"  >
                    <telerik:RadDataForm.ReadOnlyTemplate>
                        <DataTemplate>
                            <telerik:DataFormDataField DataMemberBinding="{Binding slogans, Mode=TwoWay}" Label="Slogans" Foreground="SlateGray"></telerik:DataFormDataField>
                        </DataTemplate>
                    </telerik:RadDataForm.ReadOnlyTemplate>
                </telerik:RadDataForm>
                  
            </Border>
            <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:Slogan, CreateList=true}" Height="0" LoadedData="sloganDomainDataSource_LoadedData" Name="sloganDomainDataSource" QueryName="GetSlogans" Width="0">
                <riaControls:DomainDataSource.DomainContext>
                    <ds:SloganServices />
                </riaControls:DomainDataSource.DomainContext>
            </riaControls:DomainDataSource>

    Thanks,
    Kam
  5. Answer
    Milan
    Admin
    Milan avatar
    1989 posts

    Posted 31 Mar 2011 Link to this post

    Hi Kamal Mostofi,

    Using ElementName in this scenario is required since the DomainService is not DataContext of the DataForm.  Using "{Binding dsbijslogans}" means that the binding will  use the DataContext as a source of the binding but in the snippet that you have posted the DataContext property is set.

    This is the standard behavior of Bindings that we do not control. More information about Silverlight Binding can be found here


    Regards,
    Milan
    the Telerik team
  6. Kamal Mostofi
    Kamal Mostofi avatar
    56 posts
    Member since:
    Jan 2010

    Posted 31 Mar 2011 Link to this post

    Hello Milan,

    Thanks for your reply. I fixed it as you suggested and I posted preivously. but I am still wondering why it didn't work with Telerik DomainData Services. If I use Ria domaindataservices, I can see the data in Telerik data form but not with Telerik domain control.
    Regards,
    Kam
  7. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 05 Apr 2011 Link to this post

    Hello Kamal Mostofi,

    Can you please paste me the fixed code that is working with the MS DataSource and not working with RadDomainDataSource. I am going to check what went wrong and I will do my best to provide a fix or solution for you .

    All the best,
    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
Back to Top
DevCraft banner