I am trying to check to see if data in my ultragrid has changed. I am doing this if the user closes the window, so that we can save the data automatically. I check the data set "HasChanges" and am getting False even though data in a cell was changed. What I have noticed is that this only occurs if the user has not clicked on another row in the ultragrid; if they do so, then I get True. So it seems that unless you move to another row in the ultragrid the dataset will not be updated.
Is there a way for me to tell if they have made edits to data and not moved to another row?
I am facing similar issue
Below are snippet from code:
this.usernameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.userManagementDataSet, "users.username", true));
this.systemUsersGrid.DataMember = "users"; this.systemUsersGrid.DataSource = this.userManagementDataSet;
Now, the user creates a new user using the below code :
userManagementDataSet.users.AddusersRow("NU" + _newUserCount, string.Empty, 101, "New", "User", DateTime.Now, string.Empty, string.Empty);
The dataset is updated and same is shown in textbox.
The user after editing user data closes the form
the change is not committed to the db. Saving code:
_sysUsersDa.Update(userManagementDataSet.users)
I tried the below code to try to update grid data:
var userName = usernameTextBox.Text;
systemUsersGrid.Selected.Rows[0].Cells["username"].Value = userName;
systemUsersGrid.UpdateData();
But again nothing is saved
Please suggest
The grid generally commits the data to the underlying source based on the UpdateMode property, which defaults to OnRowChangeOrLostFocus. If you want to force the active row to be updated before you try to update your data source, you could do something like:
if (this.ultraGrid1.ActiveRow != null) this.ultraGrid1.ActiveRow.Update();
-Matt