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

Can't Edit database

1 Answer 85 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Aldy
Top achievements
Rank 1
Aldy asked on 09 Nov 2015, 06:37 AM

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)
            {
            }
        }
    }

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 11 Nov 2015, 09:12 AM
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 .

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
Tags
GridView
Asked by
Aldy
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or