This is a migrated thread and some comments may be shown as answers.

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

1 Answer 50 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Þröstur
Top achievements
Rank 1
Þröstur asked on 17 Dec 2012, 03:51 AM

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>

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 17 Dec 2012, 07:38 AM
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.

Tags
GridView
Asked by
Þröstur
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or