SQLite data refresh

kahan karadağ 41 Reputation points
2022-10-26T11:29:26.737+00:00

I want the data to update the data in SQLite when I show the data which I got from SQLite in datagrid and make changes in datagrid cells. Can you help me?

254342-dbislemci.png

254372-chanceselectionpng.png

254363-p.png

Developer technologies | Windows Presentation Foundation
{count} votes

Accepted answer
  1. Hui Liu-MSFT 48,681 Reputation points Microsoft External Staff
    2022-10-27T07:16:14.577+00:00

    For modifying data and UI, you could try to look at the code below. Please let me know if there are problems.

    <StackPanel>  
            <StackPanel Orientation="Horizontal">  
                <DataGrid AutoGenerateColumns="False"  Height="200" Name="dg" Width="364"   
                       SelectedItem="{Binding Path=SelectedUser, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  
                      >  
                    <DataGrid.Columns>  
                        <DataGridTextColumn Header="ID"  Binding="{Binding Id,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></DataGridTextColumn>  
                        <DataGridTextColumn Header="Name" Binding="{Binding Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></DataGridTextColumn>  
                        <DataGridTextColumn Header="Deger"  Binding="{Binding Deger,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></DataGridTextColumn>  
      
                    </DataGrid.Columns>  
                </DataGrid>  
                <StackPanel DataContext="{Binding ElementName=dg, Path=SelectedItem}">  
                    <StackPanel Orientation="Horizontal">  
                        <Label Content="Id" Width="45"/>  
                        <TextBox Text="{Binding Id,UpdateSourceTrigger=PropertyChanged }" Width="100" Background="AliceBlue"/>  
                    </StackPanel>  
                    <StackPanel Orientation="Horizontal">  
                        <Label Content="Name"/>  
                        <TextBox Text="{Binding Name,UpdateSourceTrigger=PropertyChanged }" Width="100" Background="AliceBlue"/>  
                    </StackPanel>  
                    <StackPanel Orientation="Horizontal">  
                        <Label Content="Deger"/>  
                        <TextBox Text="{Binding Deger,UpdateSourceTrigger=PropertyChanged }" Width="100" Background="AliceBlue"/>  
                    </StackPanel>  
                </StackPanel>  
            </StackPanel>  
            <Button Content="Button" Click="Button_Click"/>  
            <DataGrid  Height="200" Name="dg1" Width="364" >  
             
            </DataGrid>  
        </StackPanel>  
    

    Codebehind:
    DataGrid dg1 is used to test if the database is updated successfully.

    254509-update-sqliet.txt

    The result:

    254635-3.gif

    ----------------------------------------------------------------------------

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.