Can't Edit database

2 posts, 0 answers
  1. Aldy
    Aldy avatar
    8 posts
    Member since:
    Sep 2015

    Posted 09 Nov 2015 Link to this post

    hello i'm trying to edit database from RadGridView, i'm using Scimore database and is connected to my GridView. I bind the itemsSource But if i change the data from Gridview, the database is not updated. why? how can i do that?

    Here's my code :

    XAML

    <Grid>
            <StackPanel x:Name="LayoutRoot">
                <telerik:RadGridView x:Name="dataGrid1"
                                     AutoGenerateColumns="True"
                                     ColumnWidth="*"
                                     ShowGroupPanel ="False"
                                     CanUserReorderColumns ="False"
                                     ItemsSource="{Binding datatable.DefaultView}">
                </telerik:RadGridView>
            </StackPanel>
        </Grid>

    CS

    public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
     
                string dbInstanceName = "C:\\Users\\Admin\\Documents\\Visual Studio 2010\\Projects\\DisplayDB\\DisplayDB\\configdb";
                ScimoreEmbedded em = new ScimoreEmbedded();
                em.Open(dbInstanceName);
     
                try
                {
                    using (ScimoreConnection cn = em.CreateConnection())
                    {
                        cn.Open();
     
                        string Query = "select idx,tag,value from config.info";
                        ScimoreCommand createCommand = new ScimoreCommand(Query, cn);
                        createCommand.ExecuteNonQuery();
     
                        ScimoreDataAdapter dataAdp = new ScimoreDataAdapter(createCommand);
                        DataTable dataTable = new DataTable("info");
                        dataAdp.Fill(dataTable);
                        dataGrid1.ItemsSource = dataTable.DefaultView;
                        dataAdp.Update(dataTable);
                    }
                }
                catch (Exception)
                {
                }
            }
        }

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 11 Nov 2015 Link to this post

    Hi Aldy,

    RadGridView will not save the changes to the database since it does not know what its type is. You need to do that explicitly by calling the corresponding method. 
    For example, you can handle RowEditEnded event and call the save changes method that will push the modifications to your db.

    Regards,
    Maya
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top