Hello all,

I have an application in which I have put a datagrid with update and delete buttons.
What I want is when I change the contents of the columns and click on update button, it should update that particular cell value into the database.

My xaml code is as follows :-

<UserControl x:Class="Petroweb_WPF_App.Petroweb_UserControls.Petroweb_ManageUploads"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="800" xmlns:my="clr-namespace:Petroweb_WPF_App.Petroweb_UserControls" HorizontalAlignment="Center" VerticalAlignment="Center">
    <Grid Height="Auto" Width="Auto">
        <DataGrid x:Name="PetroManageGrid" AutoGenerateColumns="False" ColumnWidth="*" AlternatingRowBackground="Transparent" RowBackground="Transparent">
            <DataGrid.Columns>
                <DataGridTextColumn x:Name="FName" Binding="{Binding FileName}" Width="150" Header="File Name"></DataGridTextColumn>
                <DataGridTextColumn x:Name="FPath" Binding="{Binding FilePath}" Width="450" Header="File Path"></DataGridTextColumn>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Update" x:Name="UpdateB" Width="100" Click="UpdateB_Click"></Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Delete" x:Name="DeleteB" Width="100" Click="DeleteB_Click"></Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>

Please help someone.
Thanks a lot.

This question has already been answered. Start a new discussion instead.