views:

8470

answers:

1

I have a simple datagrid example with silverlight 3, and am populating it with the .NET ria services using a DomainDataSource along with a DataPager declaratively (nothing in the code-behind), and am experiencing this problem:

The LoadSize is 30, and the Page size is 15, and when the page is loaded, the 1st and 2nd page appear correctly, but when I go beyond the 2nd page, nothing shows up in the grid.

This used to work in the silverlight 3 beta with the Mix 2009 preview of .NET Ria services, and I've got a really simple example and have verified that the Service on the web project gets called to load a new batch, but the grid doesn't show any data.

Can anyone shed any light as to why grid displays data only for the initial load of data and not subsequent batches from the pager?

Here's my xaml:

    <riaControls:DomainDataSource x:Name="ArtistSource" QueryName="GetArtist" AutoLoad="True" LoadSize="30" PageSize="15">
        <riaControls:DomainDataSource.DomainContext>
            <domain:AdminContext />
        </riaControls:DomainDataSource.DomainContext>
    </riaControls:DomainDataSource>

    <data:DataGrid Grid.Row="1" x:Name="ArtistDataGrid" ItemsSource="{Binding Data, ElementName=ArtistSource}">
    </data:DataGrid>

    <StackPanel Grid.Row="2">
        <data:DataPager Source="{Binding Data, ElementName=ArtistSource}" />
    </StackPanel>
+5  A: 

There was an exception thrown for the batches of data retrieved after the first:

The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.

After adding the following block to sort the data, the pager works properly:

<riaControls:DomainDataSource.SortDescriptors>
    <riaData:SortDescriptor PropertyPath="Name" Direction="Ascending"/>
</riaControls:DomainDataSource.SortDescriptors>

This was really causing me grief - I was going to sort the data anyway, but was just trying out the pager for the simplest case (I'm migrating from SL3 beta to SL3, and also from the Mix 2009 Preview to the the July 2009 Preview of .NET RIA Services), and got stuck on this one. I don't think normal Linq queries require orderby before calling skip, but this seems to be the case for the DataPager/DomainDataSource...

Whew!

Dennis Ward

related questions