本文介绍了具有Silverlight 3 DataGrid&的DomainDataSource DataPager .Net RIA服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Silverlight 3的简单数据网格示例,并使用DomainDataSource和DataPager声明性地使用.NET ria服务填充了它(声明中没有代码),并且遇到了此问题:

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:

LoadSize为30,页面大小为15,并且在加载页面时,第一页和第二页正确显示,但是当我超出第二页时,网格中没有任何显示.

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.

该功能过去曾在Silverlight 3 Beta中与.NET Ria服务的Mix 2009预览一起使用,并且我有一个非常简单的示例,并验证了可以调用Web项目上的Service来加载新批处理,但网格不显示任何数据.

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?

这是我的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>

推荐答案

在第一个之后获取的批处理数据抛出异常:

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

在添加以下块以对数据进行排序之后,寻呼机正常工作:

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>

这真的让我感到悲伤-无论如何我都要对数据进行排序,但只是尝试使用最简单的情况(我正在从 SL3 beta 迁移到SL3)中的传呼机,以及从 Mix 2009 Preview 到2009年7月的.NET RIA Services预览),都陷入了困境.我认为正常的Linq查询在调用skip之前不需要orderby,但是对于DataPager/DomainDataSource似乎是这种情况.

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...

哇!

这篇关于具有Silverlight 3 DataGrid&amp;的DomainDataSource DataPager .Net RIA服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 02:33