I have a domain data source in Silverlight 4. I'm setting it up in the code behind, and I'm also using a RadDataPager and RadGridView.
DomainDataSource dds = new DomainDataSource();
dds.QueryName = "MyQueryName";
dds.DomainContext = ctx;
dds.LoadSize = 10;
dds.PageSize = 10;
dds.AutoLoad = true;
radDataPager1.PageSize = 10;
radDataPager1.Source = dds.Data;
radGridView1.ItemsSource = dds.Data;
dds.Load();
The first time this loads, the dds.Data.Count is 8, and only 8 items show up in the grid view, even though the dds.Data.PageSize is 10. After I page to the next page, all 10 objects are loaded like they should be.
I'm new to Silverlight, and have no idea what is going on here. Am I loading the data wrong? Any ideas?
This behavior can be caused by wrong set of Key attribute in your model class. If in the result query, rows with Key field are duplicated, then DataGrid will take only first.
Example (book store info ): Your result class (BookPriceInfo.cs) looks like this:
And if you have query result returned from database :
Then DataGrig will show only this :
this happens because of DataGrid will 'distinct' the results by field marked as
Key
(get only first row from all rows with same BookId), because it should be uniq for all rows.Solution
Remove
Key
attribute from field which will have duplicated values (BookId) and set it to field which will have uniqe values for all rows (you can add some column like BookPriceId, which will be uniqe).Query result:
After that you should see all rows returned by query. Hope this helps :)