private void ViewWinLoaded(object sender, RoutedEventArgs e)
{
var stud = from s in data.Students
select s;
Student[] st=stud.ToArray<Student>();
datagrid.ItemsSource = st;
}
the above one is my C# code.
<DataGrid x:Name="datagrid" HorizontalAlignment="Left" Height="232" VerticalAlignment="Top" Width="461">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Path=StudentID}" ClipboardContentBinding="{x:Null}" Header="StudentID"/>
<DataGridTextColumn Binding="{Binding Path=FirstName}" ClipboardContentBinding="{x:Null}" Header="First Name"/>
<DataGridTextColumn Binding="{Binding Path=LastName}" ClipboardContentBinding="{x:Null}" Header="Last Name"/>
<DataGridTextColumn Binding="{Binding Path=Gender}" ClipboardContentBinding="{x:Null}" Header="Gender"/>
<DataGridTextColumn Binding="{Binding Path=GPA}" ClipboardContentBinding="{x:Null}" Header="GPA"/>
</DataGrid.Columns>
</DataGrid>
what I am trying to achive is to use my own column name, not the column name in the dB. But when i run the code, it displays my custom column and the column name from the db at the same time(cascaded name)
Prevent the DataGrid from generating columns by setting AutoGenerateColumns property to false.
<DataGrid x:Name="datagrid" AutoGenerateColumns="False"
HorizontalAlignment="Left" Height="232" VerticalAlignment="Top" Width="461">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With