0
我的应用程序要求将WPF DataGrid
控件中所做的更改保存回DataTable
。我已经成功地将DataGrid
中的数据保存到DataTable
,但从DataGrid
保存的数据未显示我所做的更改,它仅显示DataGrid
首次填充时已存在的数据。WPF将DataGrid中的更改保存到数据表中
我有这么远:
public void UpdateQueueData(object sender, DataGridRowEditEndingEventArgs e)
{
if (e.EditAction == DataGridEditAction.Commit)
{
DataGridRow dgRow = e.Row;
DataRowView rowView = dgRow.Item as DataRowView;
DataRow drItem = rowView.Row;
Queue.Rows.RemoveAt(e.Row.GetIndex());
Queue.ImportRow(drItem);
WriteXML();
}
}
这工作,但它不保存更改,它只是保存DataRow
,因为它是它在DataGrid
改变之前。
我错过了什么吗?
遗憾的是变更后的DataRow的,我的意思是在DataGrid中所做的更改均没有出现在DataRow中:drItem时正在触发事件。 – 2009-12-10 00:55:28