Click here to Skip to main content
15,885,036 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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
Updated 4-Jan-12 7:11am
v2

1 solution

Haven't used this control so not sure about this but should you use ItemsSource. So:
C#
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.
 
Share this answer
 
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900