[英]How to save row changes in DevExpress GridView with the EmbeddedNavigator
I am using the EmbeddedNavigator's Add, Edit and Remove buttons. 我正在使用EmbeddedNavigator的“添加”,“编辑”和“删除”按钮。 I have subscribed to the
gridControl1_EmbeddedNavigator_ButtonClick
event and there I check which button is clicked. 我已经订阅了
gridControl1_EmbeddedNavigator_ButtonClick
事件,并在其中检查单击了哪个按钮。
The problem is that when I edit a cell and I press save changes( EndEdit
) I don't see the new values. 问题是,当我编辑单元格并按保存更改(
EndEdit
)时,看不到新值。 Here is the code that I have: 这是我的代码:
private void gridControl1_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
{
if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.EndEdit)
{
if (MessageBox.Show("Do you want to save the changes?", "Save changes?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
{
var rowHandle = gridView1.FocusedRowHandle;
// Here if the port is null by default, when I change it to 25
// I still get an empty string
var port = Convert.ToString(gridView1.GetRowCellValue(rowHandle, "ftpPort"));
var ftpConfig = new FtpConfiguration() { ftpPort = port };
// Update and save
context.UpdateFtpConfiguration(ftpConfig);
context.Save();
}
else
e.Handled = true;
}
}
Maybe I have to append them to the row first, but how? 也许我必须先将它们附加到该行中,但是如何?
Try to post your changes to underlying DataSource
before saving it: 在保存更改之前,请尝试将更改发布到基础
DataSource
:
if (gridView1.IsEditing)
gridView1.CloseEditor();
if (gridView1.FocusedRowModified)
gridView1.UpdateCurrentRow();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.