我创建了一个示例 silverlight 应用程序,并尝试使用数据库表中的数据填充 DataGrid。
我使用 WCF Ria 服务和实体框架创建了这个应用程序。当我在网络浏览器中运行应用程序时,我可以看到数据网格中仅显示 2 行,而查询应返回更多行数。我已将 SQL Server 探查器附加到数据库以查看发送的查询内容。没有问题,查询返回所有行。
我在 MainPage.xml 中的 XAML 如下。
<sdk:DataGrid AutoGenerateColumns="True" Name="RDataGrid"/>
在后面的代码中,我绑定到数据网格如下:
Server.Service.RDomainContext context = new Server.Service.RDomainContext();
RDataGrid.ItemsSource = context.s_structures;
LoadOperation<Server.Service.s_structures> loadop = context.Load(context.GetS_structuresQuery());
我是 silverlight 的新手,我不明白如何找出应用程序中出了什么问题。非常感谢任何帮助。
顺便说一句,我已将我的应用程序分成不同的模块,如下 链接。
提前致谢。
I have created a sample silverlight application and trying to populated DataGrid with Data from a database table.
I have created this application using WCF Ria Services and Entity framework. When I run my application in the webbrowser I can see only 2 rows being displayed in the datagrid while the query should return more number of rows. I have attached SQL Server profiler to the database to see what the query is being sent. There is no problem in it, the query is returning all the rows.
My XAML in the MainPage.xml is as follows.
<sdk:DataGrid AutoGenerateColumns="True" Name="RDataGrid"/>
and in the code behind I am binding to datagrid as follows:
Server.Service.RDomainContext context = new Server.Service.RDomainContext();
RDataGrid.ItemsSource = context.s_structures;
LoadOperation<Server.Service.s_structures> loadop = context.Load(context.GetS_structuresQuery());
I am new to silverlight and I did not understand how to find out whats going wrong in the application. Any help much appreciated.
BTW i have broke my application in to different modules following this link.
Thanks in Advance.
发布评论
评论(1)
终于我找到了这个问题的答案。问题是我将 ItemsSource 设置为错误的内容。我应该设置 RDataGrid.ItemsSource = loadop.Entities。
Finally I found the answer for this question. The problem was I was setting the ItemsSource to wrong thing. I should set the RDataGrid.ItemsSource = loadop.Entities.