Datagrid 从源中复制一项

发布于 2024-11-19 12:29:26 字数 2064 浏览 4 评论 0原文

我有一个 RIA 服务,用于返回学校列表并填充数据网格。该数据网格在整个网格中复制第一个结果,而不是在其自己的行中显示源中的每个项目。

服务如下

var schools1 = (from i in DataContext.PrevSchools
                       join skl in DataContext.SchoolLists on i.School_id equals skl.School_Id
                       where i.Email_Address == email
                       select new PreviousSchools
                                  {
                                      PrevSchoolsId = i.PrevSchools_id,
                                      AppEmail = i.Email_Address,
                                      SchoolId = i.School_id,
                                      DateAttended = i.YearsAttended,
                                      Study = i.Study, 
                                      Credit = i.Credit, 
                                      CompleteStatus = i.Complete_Status,  
                                      Award = i.Award, 
                                      SchoolName = skl.School_name
                                  }).Union(from i in DataContext.PrevSchools
                       join skl1 in DataContext.Schools on i.School_id equals skl1.School_id
                       where i.Email_Address == email && i.School_type_id == 1
                       select new PreviousSchools
                       {
                           PrevSchoolsId = i.PrevSchools_id,
                           AppEmail = i.Email_Address,
                           SchoolId = i.School_id,
                           DateAttended = i.YearsAttended,
                           Study = i.Study,
                           Credit = i.Credit,
                           CompleteStatus = i.Complete_Status,
                           Award = i.Award,
                           SchoolName = skl1.School_name
                       }).OrderBy(q => q.SchoolName);

        return schools1;

数据绑定是:

this.PrevSchools.prevSchoolDataGrid.DataContext = SchoolsList;

SchoolList 是一个 ObservableCollection,它被设置为一个列表,也是一个 IEnumerable,它仍然产生重复的结果。

I have a RIA service that is to return a list of schools and populate a datagrid. This datagrid is duplicating the first result throughout the entire grid, as opposed to showing each item from source in its own row.

The service is as follows

var schools1 = (from i in DataContext.PrevSchools
                       join skl in DataContext.SchoolLists on i.School_id equals skl.School_Id
                       where i.Email_Address == email
                       select new PreviousSchools
                                  {
                                      PrevSchoolsId = i.PrevSchools_id,
                                      AppEmail = i.Email_Address,
                                      SchoolId = i.School_id,
                                      DateAttended = i.YearsAttended,
                                      Study = i.Study, 
                                      Credit = i.Credit, 
                                      CompleteStatus = i.Complete_Status,  
                                      Award = i.Award, 
                                      SchoolName = skl.School_name
                                  }).Union(from i in DataContext.PrevSchools
                       join skl1 in DataContext.Schools on i.School_id equals skl1.School_id
                       where i.Email_Address == email && i.School_type_id == 1
                       select new PreviousSchools
                       {
                           PrevSchoolsId = i.PrevSchools_id,
                           AppEmail = i.Email_Address,
                           SchoolId = i.School_id,
                           DateAttended = i.YearsAttended,
                           Study = i.Study,
                           Credit = i.Credit,
                           CompleteStatus = i.Complete_Status,
                           Award = i.Award,
                           SchoolName = skl1.School_name
                       }).OrderBy(q => q.SchoolName);

        return schools1;

The Databinding is:

this.PrevSchools.prevSchoolDataGrid.DataContext = SchoolsList;

The SchoolList is an ObservableCollection, it was set as a list and also a, IEnumerable, and it still yielded the duplicated results.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

年少掌心 2024-11-26 12:29:26

已修复,这是 Model 类中的错误,密钥设置为错误的属性

Fixed it, it was an error in the Model class, the key was set to the wrong property

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文