Click here to Skip to main content
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 OriginalGriff 190
1 PIEBALDconsult 150
2 BillWoodruff 148
3 DamithSL 140
4 Jochen Arndt 125
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 4 Jan 2012
Copyright © CodeProject, 1999-2014
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