开发者

Datagrid duplicates one item from source

开发者 https://www.devze.com 2023-03-19 16:47 出处:网络
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

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 als开发者_运维问答o a, IEnumerable, and it still yielded the duplicated results.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号