SteValue method does not work.  
Author Message
AlexBB





PostPosted: Visual C# General, SteValue method does not work. Top

It is very frustrating to find out after hours of development that a method used so widely does not work as intended. Is it supposed to modify values in a DataRow or not What is the meaning of .SetValue semantically

I find that if I have DataRow[] dtRows and want to modify some values in the fields the only way to do it is to use

foreach (DataRow row in dtRows)

row[0] = someValue;

If I try:

dtRows[0].ItemArray.SetValue (someValue, 0);

it won't work. it compiles, execution takes place but the values remain unchanged. Am I missing something

Thanks.




Visual C#8  
 
 
csharprocks.com





PostPosted: Visual C# General, SteValue method does not work. Top

The problem is the 0 in setvalue. The value needs to increment, for example:

dtRows[0].ItemArray.SetValue ("Test1", 0);

dtRows[0].ItemArray.SetValue ("Test1", 1);

dtRows[0].ItemArray.SetValue ("Test1", 2);

dtRows[0].ItemArray.SetValue ("Test1", 3);

Best regards,

Craig Maslowski MCT