How to edit entry in RadGridView in WPF so the input goes to database

2 posts, 0 answers
  1. Þröstur
    Þröstur avatar
    1 posts
    Member since:
    Dec 2012

    Posted 16 Dec 2012 Link to this post

    I´m setting up a RadGridView in my WPF application. I´ve already created a database and connected a data source to my Grid. I want the user to be able to edit the entries in the RadGridView and I want the database to update according the that.

    How is that possible ?

    here is my code:

    <Window x:Class="TheHomeApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" 
        Height="780" 
        Width="1012" 
        xmlns:my="clr-namespace:TheHomeApp" 
        Loaded="Window_Loaded" 
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:telerikControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls">
    
    <Window.Resources>
        <my:HeimilisAppidDBDataSet x:Key="heimilisAppidDBDataSet" />
        <CollectionViewSource x:Key="accountingViewSource" Source="{Binding Path=Accounting, Source={StaticResource heimilisAppidDBDataSet}}" />
    </Window.Resources>
    
    
    <Grid DataContext="{StaticResource accountingViewSource}">
        <telerik:RadGridView x:Name="AccountingGridView" GroupRenderMode="Flat"
                             ShowGroupPanel="False"
                             ItemsSource="{Binding}"
                             MinHeight="386"                           
                             IsReadOnly="False"
                             MaxHeight="700" CanUserFreezeColumns="False"
                             RowIndicatorVisibility="Collapsed"
                             AutoGenerateColumns="False"                          
                             ShowColumnFooters="True" 
                             Margin="12,29,0,12" 
                             HorizontalAlignment="Left"
                             Width="452"
                             telerikControls:StyleManager.Theme="Windows8"
                             GridLinesVisibility="Both"
                             ValidatesOnDataErrors="None"
                             >
    
            <telerik:RadGridView.Columns >
                <telerik:GridViewDataColumn Header="Liður"
                                            DataMemberBinding="{Binding nameAccounting}"
                                            Width="150" />
                <telerik:GridViewDataColumn Header="Áætluð upphæð"
                                            DataMemberBinding="{Binding amountAccounting}"
                                            Width="150"
                                            DataFormatString="{}{0:C}"/>                                           
                <telerik:GridViewDataColumn Header="Raunupphæð"
                                            DataMemberBinding="{Binding actualAmountAccounting}"
                                            DataFormatString="{}{0:C}"
                                            Width="*" />
    
            </telerik:RadGridView.Columns>
    
        </telerik:RadGridView>
        <telerik:RadChart Content="{Binding}" Height="288" HorizontalAlignment="Left" Margin="506,42,0,0" Name="accountingRadChart" VerticalAlignment="Top" Width="457" />
    </Grid>
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 17 Dec 2012 Link to this post

    Hi,

     Maybe you need to check our RadEntityFrameworkDataSource demos. 

    All the best,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top