[英]How to save row changes in DevExpress GridView with the EmbeddedNavigator
我正在使用EmbeddedNavigator的“添加”,“編輯”和“刪除”按鈕。 我已經訂閱了gridControl1_EmbeddedNavigator_ButtonClick
事件,並在其中檢查單擊了哪個按鈕。
問題是,當我編輯單元格並按保存更改( EndEdit
)時,看不到新值。 這是我的代碼:
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;
}
}
也許我必須先將它們附加到該行中,但是如何?
在保存更改之前,請嘗試將更改發布到基礎DataSource
:
if (gridView1.IsEditing)
gridView1.CloseEditor();
if (gridView1.FocusedRowModified)
gridView1.UpdateCurrentRow();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.