Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Binding of two dataGrid with same table columns resulted in repeating values in both dataGirds

$
0
0

Two different DataTables are coming from query, both DataTable contains person_name and person_gender coming from same table person, hence have same column name.

In XAML i'm Binding both DataGrids first two columns with person_name and person_gender which means whenever person_name and person_gender value is updated it is added to the columns, here is the code:

                

<DataGrid Name="datagrid" ItemsSource="{Binding Path=Collection}" Background="Transparent" AutoGenerateColumns="False"  Width="360" ClipToBounds="True" IsReadOnly="True" Height="350" HorizontalAlignment="Left" Margin="0,70,0,0" VerticalAlignment="Top" >
                    <DataGrid.Columns>
                        <DataGridTextColumn Width="90" Header="Name" Binding="{Binding Path=person_name}" />
                        <DataGridTextColumn Header="Gender" Binding="{Binding Path=person_gender}" />
                        <DataGridTextColumn Header="Rating" Binding="{Binding Path=doctor_avgratting}" />
                        <DataGridTextColumn Header="Qualification" Binding="{Binding Path=doctor_qualification}" />
                    </DataGrid.Columns>

                <DataGrid Name="datagridstaff"  Background="Transparent" AutoGenerateColumns="False"  Width="360" ClipToBounds="True" IsReadOnly="True" Height="350" HorizontalAlignment="Left" Margin="400,70,0,0" VerticalAlignment="Top" >
                    <DataGrid.Columns>
                        <DataGridTextColumn Width="90" Header="Name" Binding="{Binding Path=person_name}" />
                        <DataGridTextColumn Header="Gender" Binding="{Binding Path=person_gender}" />
                        <DataGridTextColumn Header="Rating" Binding="{Binding Path=staff_avgratting}" />
                        <DataGridTextColumn Header="Qualification" Binding="{Binding Path=staff_qualification}" />

                    </DataGrid.Columns>

 And this is its result:

Doctor and staff name and gender is only added to both columns not ratting and qualification, its because of same name binding to both DataGrids.

How can i remove staff row from Doctor's DataGrid and vice versa?


Student of Software Engineering.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>