tags:

views:

32

answers:

1

Hi,

I have a third party grid that is binded to an object. Each column is binded to a property of the object. Now, I get the selected row from the grid and cast to the object like:

var item = myGrid.ActiveRow.ListObject as Bench; 
item.RequestedBy = WindowsIdentity.GetCurrent().Name; 
_controller.Process(item);

The problem is that as soon as the item.RequestedBy property is changed the Grid displays the username in the column. This is because the row is binded to an object. What can I do to not show the username in the column as soon as the value is assigned.

+1  A: 

Assuming that your third-party's ListObject class implements the ICloneable interface (which it should), one suggestion would be to Clone the object so that you are not working with the same reference.

var item = myGrid.ActiveRow.ListObject.Clone() as Bench; 
item.RequestedBy = WindowsIdentity.GetCurrent().Name; 
_controller.Process(item);

If the Clone method is not available in the ListObject class, you could implement it in your Bench class.

Jose Basilio