Chào mọi người, tôi cần giúp đỡ vấn đề như sau:
Tôi tạo 1 Form mới trong Visual Studio và sử dụng GridControl của Devexpress để load dữ liệu, đoạn code như sau:
private void Form1_Load(object sender, EventArgs e)
{
string connectionString = @"server=(local)\sqlexpress;database=nwind;Integrated Security=SSPI;";
SqlConnection sqlconnection = new SqlConnection(connectionString);
DataTable dataTable = new DataTable();
SqlCommand sqlCommand = new SqlCommand();
sqlCommand.CommandText = "Select * from employees";
sqlCommand.Connection = sqlconnection;
sqlCommand.CommandType = CommandType.Text;
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
sqlDataAdapter.Fill(dataTable);
gridControl1.DataSource = dataTable;
}
Hiện tại đã load dữ liệu từ bảng employees của Database nwind lên GridControl thành công.
Vào Properties của GridControl chọn thuộc tính UseEmbbededNavigator là True.
Tôi thêm 1 dòng mới vào dữ liệu và click EndEdit thì thấy dữ liệu đã hiển thị lên GridControl, nhưng khi đóng Form và chạy lại (F5), thì không thấy dòng dữ liệu mới thêm vào. Điều này có nghĩa là khi ta Append từ Navigator nó chỉ mới hiển thị lên GridControl và chưa cập nhật vào Database. Vậy làm thế nào để nó cập nhật vào Database?