gridviev add new row problem
- by Dominating
My relation is from two tables - table A and table B. B has fk ID pointing to A.ID. In gridview for sourse i have choosen A. When I append new row in A its ok.. But with this action I want to add new row in B too and init it with some values which are copies from row number Row given as argument in PasteCopy
private void PasteCopy(int Row)
{
XPDataTableObject forCopy = gridView1.GetRow(Row) as XPDataTableObject;
gridViewEcnMaster.AddNewRow();
XPDataTableObject toCopy = gridView1.GetRow(GridControl.NewItemRowHandle) as XPDataTableObject;
SetA(forCopy);// working
SetB(ref toCopy, forCopy);
XPDataTableObject toCopy1 = gridView1.GetFocusedRow() as XPDataTableObject;
XPCollection historyForCopy = toCopy1.GetMemberValue("FK___B__ID") as XPCollection;
foreach (XPDataTableObject item in historyForCopy)
{
MessageBox.Show(item.GetMemberValue("USER").ToString());
}
}
public void SetB(ref XPDataTableObject toCopy, XPDataTableObject forCopy)
{
XPCollection historyToCopy = toCopy.GetMemberValue("FK__B__ID") as XPCollection;
XPCollection historyForCopy = forCopy.GetMemberValue("FK__B__ID") as XPCollection;
XPClassInfo cinfo = session.GetClassInfo(typeof(SPM_ECN_DataSet.BDataTable));
foreach (XPDataTableObject item in historyForCopy)
{
XPDataTableObject historyRecord = new XPDataTableObject(session, cinfo);
historyRecord.SetMemberValue("USER", GetCurWinUser().ToString());
historyRecord.SetMemberValue("ID", forCopy.GetMemberValue("ID"));//if not set == null
historyToCopy.Add(historyRecord);
}
}
public void SetA(XPDataTableObject forCopy)
{
gridView1.SetFocusedRowCellValue("VERSION", 1);
}
What is wrong with this? why its locking all my application after i do this?