Hi Guy, i Need your help please.
I receive a Data of Type List<classdata> from a WebService. and insert it in a DataTable this List is Static. see the Code:
private static List<ClassData> DataList;
public static void DataListUpdate()
{
DataList = webservice.GetCommissioningClientView().ToList();
}
public static DataTable GetDataListTable()
{
try
{
DataTable DTable = new DataTable();
DTable.Columns.Add("DataDesc");
DTable.Columns.Add("DataID");
var SortDataByPriority = from table in DataList
orderby table.highestPriority descending
select table;
foreach (var DataObject in SortDataByPriority )
{
ClassData orderData = DataObject as ClassData;
foreach (var element in DataObject.GetDetails)
{
row = DTable.NewRow();
row[0] = element.MatDesc;
row[1] = element.EntryMaterialID;
if (DTable.Columns.Contains(DataObject.DataID))
{
if((DTable.Rows[foundRowIndex][DataObject.DataID] as DataElement) != null);
{
(DTable.Rows[foundRowIndex][DataObject.DataID] as DataElement).ElementQuantity += Element.EntryQuantity ;
}
else
{
DTable.Rows[foundRowIndex][DataObject.DataID] = ObjectElement;
}
}
after verification i observe that the ObjectClass Propertie value has been changed too.
for example
DataElement.Quantity = 23 // Initial Value
after Addition
DataElement.Quantity = 46; not my Purpose.
my purpose is just to Change a value of a a Object insert a new Value in my DataTable and the OjectClass stay without Change.
like this;
##before Addition
DataElement.Quantity = 23 // Initial
##after Addition
DataElement.Quantity = 23 // Object stay intact
##DataTable
Object with a value: DataElement.Quantity = 46
but when i made a Change the Value of the Propertie it Change a value of my ObjectClass.
Please where i'm doing wrong??