A
Alberta Smith
I have two tables and a parent-child relationship between them. On the
child table i created a calculated field that goes to the parent table
to get a value (child table has a code and parent table has a
description for that code:Expresion=parent(myrelation).mydescfield). I
have a form showing a parent-datatable row and a datagrid bound to the
relation showing related child rows. I use a DataViewManager as
datasource to sort data.
I create programatically a new row (using currencymanager.addnew(),
currencymanager.endcurrentedit() of the relation) in the child table
and the datagrid shows it correctly. Then i modify a field in that new
row on the datagrid. Then i move to another row in the datagrid and it
explodes:
Excepción no controlada: System.NullReferenceException: Referencia a
objeto no establecida como instancia de un objeto.
at System.Data.DataView.IsOriginalVersion(Int32 index)
at System.Data.DataRowView.GetColumnValue(DataColumn column)
at System.Data.DataColumnPropertyDescriptor.GetValue(Object
component)
at System.Windows.Forms.DataGridColumnStyle.GetColumnValueAtRow(CurrencyManager
source, Int32 rowNum)
at System.Windows.Forms.DataGridTextBoxColumn.Paint(Graphics g,
Rectangle bounds, CurrencyManager source, Int32 rowNum, Brush
backBrush, Brush foreBrush,
...
If i remove the calculated field from the child table and everything
works ok. But i need to show this calculated field in the grid so i
can't just remove it. And also, if i use the dataset as datasource
instead of the dataviewmanager everythinks works (except the tables
doesn't show ordered first time).
I am frustrated. Any hint?
child table i created a calculated field that goes to the parent table
to get a value (child table has a code and parent table has a
description for that code:Expresion=parent(myrelation).mydescfield). I
have a form showing a parent-datatable row and a datagrid bound to the
relation showing related child rows. I use a DataViewManager as
datasource to sort data.
I create programatically a new row (using currencymanager.addnew(),
currencymanager.endcurrentedit() of the relation) in the child table
and the datagrid shows it correctly. Then i modify a field in that new
row on the datagrid. Then i move to another row in the datagrid and it
explodes:
Excepción no controlada: System.NullReferenceException: Referencia a
objeto no establecida como instancia de un objeto.
at System.Data.DataView.IsOriginalVersion(Int32 index)
at System.Data.DataRowView.GetColumnValue(DataColumn column)
at System.Data.DataColumnPropertyDescriptor.GetValue(Object
component)
at System.Windows.Forms.DataGridColumnStyle.GetColumnValueAtRow(CurrencyManager
source, Int32 rowNum)
at System.Windows.Forms.DataGridTextBoxColumn.Paint(Graphics g,
Rectangle bounds, CurrencyManager source, Int32 rowNum, Brush
backBrush, Brush foreBrush,
...
If i remove the calculated field from the child table and everything
works ok. But i need to show this calculated field in the grid so i
can't just remove it. And also, if i use the dataset as datasource
instead of the dataviewmanager everythinks works (except the tables
doesn't show ordered first time).
I am frustrated. Any hint?