DataGrid中的单元格根本不显示数据

时间:2015-01-11 17:22:25

标签: c# sql wpf

我正在尝试将DataTable绑定到DataGrid。但DataGrid的行数与DataTable类似,所有单元格都是空的!我做错了什么?

<DataGrid Name="ScheduleCommon" Margin="2,0,4,0" RenderTransformOrigin="-0.21,0.4" AutoGenerateColumns="False" EnableRowVirtualization="True" ItemsSource="{Binding}">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="ФИО" Binding="{Binding Path = Name}"/>
                                <DataGridTextColumn Header="Специализация" Binding="{Binding apt.Specialisation}"/>
                                <DataGridTextColumn Header="Дата" Binding="{Binding apt.WorkDay, StringFormat=dd MM yyyy}"/>
                                <DataGridTextColumn Header="С" Binding="{Binding apt.TimeBegin}"/>
                                <DataGridTextColumn Header="До" Binding="{Binding apt.TimeEnd}"/>
                            </DataGrid.Columns>
                        </DataGrid>

>             InitializeComponent();
> 
>             this.sqlc = sqlc;
> 
>             SqlCommand cmd = new SqlCommand();
>             cmd.CommandText = "SELECT Doctor.Name as 'ФИО', Specialisation.Specialisation                                  as 'Специализация', DoctorVisitingDay.WorkDay as'Рабочий день'," +
>                               " DoctorVisitingDay.TimeBegin as 'C', DoctorVisitingDay.TimeEnd as 'До' FROM Doctor, Specialisation, DoctorVisitingDay" +
>                               " WHERE Doctor.Specialisation = Specialisation.ID AND Doctor.ID = DoctorVisitingDay.IDDoctor";
>             cmd.CommandType = CommandType.Text;
>             cmd.Connection = this.sqlc;
>             adp = new SqlDataAdapter(cmd);
>             dtSch = new DataTable("Schedule");
>             adp.Fill(dtSch);            
>             
>             ScheduleCommon.ItemsSource = dtSch.DefaultView;

0 个答案:

没有答案