Click here to Skip to main content
11,415,734 members (83,497 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF C#4.0 DataGrid
 
using C1.WPF.DataGrid;
 
        public static OleDbConnection connection;
        public static OleDbDataAdapter da;       
        
        public static DataSet ds = new DataSet();
        public static DataTable dt;
        OleDbCommandBuilder cmd;
 
        public static string connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/Project/A&T.accdb";
        public static string cmdstring;
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            cmdstring = "SELECT*FROM DP";
            connection = new OleDbConnection(connectionstring);
            connection.Open();
            da = new OleDbDataAdapter(cmdstring, connection);
            dt = new DataTable();
            da.Fill(dt);         
            
 
            c1DataGrid1.DataContext = dt;    
 
        }
 
        private void button2_Click(object sender, RoutedEventArgs e)
        {    
 

            cmd = new OleDbCommandBuilder(da);
            dt.GetChanges();
            if (dt.GetChanges() != null)
            {
                da.Update(dt);
            }
            dt.AcceptChanges();
 
            
           
        }
 

in this code i use a third party product Component one Datagrid.the problem is while clicking Button2 the change should be updated back to the database. this is not happening.if I replace the c1DataGrid1 with Datagrid of WPF everything working fine what should i do. any sort of help will be appreciated

update is happening only when a cell in any other row is clicked . otherwise it is not happening I want to avoid this situation

Regards

Iqbal
Posted 4-Jan-12 3:42am
Edited 4-Jan-12 8:11am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Haven't used this control so not sure about this but should you use ItemsSource. So:
c1DataGrid1.ItemsSource= dt; 
Also many grid components have a separate method that reflects the changes in the grid to the underlying data source, so check that there isn't anything like that which should be called.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,270
1 OriginalGriff 7,512
2 Maciej Los 3,710
3 Abhinav S 3,325
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web01 | 2.8.150427.4 | Last Updated 4 Jan 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100