Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi all

I have 2 columns in my database table

name value
a     0
b     0
c     0
d     0

so now i want is if the value is 0 then the the checkboxes will be unchecked and when user check the checkbox the value should update to 1

Please tell me how to fetch the data and update the checkboxes.

At the first time i have to load the default value from database.later user will update and save.

This is my datagrid

XML
<my:DataGrid Name="dgProducts" AutoGenerateColumns="False" Grid.Row="1" Grid.RowSpan="3" Grid.ColumnSpan="2" CanUserAddRows="False">
            <my:DataGrid.Columns>
                <my:DataGridTextColumn Header="Name" Binding="{Binding Path=ProductName}" Width="300"/>               
               
                <my:DataGridTemplateColumn>
                    <my:DataGridTemplateColumn.Header>
                        <CheckBox Content="Visible" Click="CheckBox_Click" Name="CheckBox1" />
                    </my:DataGridTemplateColumn.Header>
                    <my:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox Name="chkDiscontinue" IsChecked="{Binding Path=Discontinue,Mode=TwoWay}" Margin="45 2 0 0" Click="chkDiscontinue_Click" />
                        </DataTemplate>
                    </my:DataGridTemplateColumn.CellTemplate>
                </my:DataGridTemplateColumn>
            </my:DataGrid.Columns>
        </my:DataGrid>


Thank you
Posted
Updated 13-Aug-13 22:01pm
v3
Comments
Maciej Los 14-Aug-13 4:05am    
What is an exact question? Where is a problem? What want you know to take a step ahead?

Please, read my comment to the question.

Have you seen this: datagrid with checkbox in wpf[^]?

Please, use a SearchBox[^].
 
Share this answer
 
Write Converter to convert from 0 or 1 to True or false and bind with checkBox:


<checkbox content="Visible" click="CheckBox_Click" name="CheckBox1" ischecked="{Binding" path="value,Converter={StaticRsource MyConverter"}} />


Syntax may be different but follow this concept . I believe this will help you.


Feel Free to ask any question.
Raman Kumar
 
Share this answer
 
v3

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