User (Old forums)MemberMay 29, 2006 at 10:19 amPost count: 23064
I’ve created a combination of bound and unbound grid.
In the AddingDataRow event, which is called when the dataset is bound to the grid, im trying to fill the unbound cells with related information.
This works for the first item which is added to the grid, as this item is the current item of the dataset (i presume). When the second item is added, i am still getting data from the first item in the dataset.
This is the code i use in the AddingDataRow event
DataRowView curRowView = m_SerialViewBindingSource.Current as DataRowView;
SerialViewDataSet.SerialRow curSerialRow = curRowView.Row as SerialViewDataSet.SerialRow;
string Serial = curSerialRow.SerialNumber;
Now, im in doubt if this is normal behaviour, or that, somehow, i can know which row in the dataset is being accessed by the gridcontrol.
Thanks in advance, for any leads in the right direction!
Imported from legacy forums. Posted by opicron (had 2385 views)User (Old forums)MemberMay 30, 2006 at 4:39 pmPost count: 23064
In the AddingDataRow, you need to use the e.DataRow to read or write to the row currently loading :
e.DataRow.Cells[ x ].Value = “something”;
For accessing the source (dataset) of the current row, do it through the SourceObject :
which would be equivalent to the DataRowView in your case.
Imported from legacy forums. Posted by André (had 339 views)User (Old forums)MemberMay 31, 2006 at 3:29 amPost count: 23064
Thanks a load AndreC,
After doing some casting I’ve been able to retrieve all datarows I need! You have been very helpfull. I’ll post the information here to make this thread complete.
// cast the SourceObject to an DataRowView
DataRowView curSerialRowView = (DataRowView)e.DataRow.SourceObject;
//retrieve the SerialRow from the DataRowView
SerialViewDataSet.SerialRow currentSerialRow = curSerialRowView.Row as SerialViewDataSet.SerialRow;
//retrieve child relation rows (casted from DataRow)
SerialViewDataSet.GuaranteeRow currentGuaranteeRow = (SerialViewDataSet.GuaranteeRow)currentSerialRow.GetChildRows(“FK_Serial_Guarantee”);
//now you have a system.array with the datarows
I hope this helps others with the same kind of problem.
Imported from legacy forums. Posted by opicron (had 3596 views)
- You must be logged in to reply to this topic.