WPF DataGrid绑定问题
xaml里设置:<DataGrid.Columns><DataGridHyperlinkColumnHeader="标题"Binding="{BindingPath=Ti...
xaml里设置:
<DataGrid.Columns>
<DataGridHyperlinkColumn Header="标题" Binding="{Binding Path=Title}"/>
<DataGridTextColumn Header="日期" Binding="{Binding Path=Date}" />
<DataGridTextColumn Header="作者" Binding="{Binding Path=Author}" />
</DataGrid.Columns>
CS里:
SqlDataAdapter da = new SqlDataAdapter("SELECT Title,Date,Author FROM AddData", conn);
System.Data.DataSet ds = new System.Data.DataSet();
da.Fill(ds);
dataGrid1.ItemsSource = ds.Tables[0].DefaultView;
问题是这样做了以后显示了两样数据:如图 展开
<DataGrid.Columns>
<DataGridHyperlinkColumn Header="标题" Binding="{Binding Path=Title}"/>
<DataGridTextColumn Header="日期" Binding="{Binding Path=Date}" />
<DataGridTextColumn Header="作者" Binding="{Binding Path=Author}" />
</DataGrid.Columns>
CS里:
SqlDataAdapter da = new SqlDataAdapter("SELECT Title,Date,Author FROM AddData", conn);
System.Data.DataSet ds = new System.Data.DataSet();
da.Fill(ds);
dataGrid1.ItemsSource = ds.Tables[0].DefaultView;
问题是这样做了以后显示了两样数据:如图 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询