Click here to Skip to main content
15,941,894 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want bind WPF datagrid by dataset.Please Write me the proper C# code.
Posted

1 solution

Hi,

Try the following

XML
<DataGrid Height="500" Width="750" Canvas.Left="37" Canvas.Top="41" x:Name="dgTest" ItemsSource="{Binding}">
            <DataGrid.Columns>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox x:Name="Test" Visibility="{Binding Path=Flag,Converter={StaticResource boolToVis}}"></CheckBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>

                </DataGridTemplateColumn>

            </DataGrid.Columns>

        </DataGrid>




Code Behind:

CSS
DataView dv = dsEmp.Tables[0].DefaultView;
            dgTest.DataContext = dv;
            dv.AllowNew = false;



Hope this helps...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900