G
Guest
Ok, I can't believe what I am seeing. I am sure I do this other places with
no problems, but I sure can't here.
I have some code that is indexing into the ItemArray in a DataSet's DataRow.
I basically want to change the value of the data stored at a particular
index in the ItemArray. Ideally, I would like for my code to look like this
(pay attention to the index of ItemArray):
row.ItemArray[(int)GridColumnIndexes.Part - 1] =
itemArray[(int)GridColumnIndexes.Part - 1].ToString().Substring(3);
This would allow me to chop off the first 3 characters.
However, the expression (int)GridColumnIndexes.Part - 1 is not evaluating to
the correct index in the ItemArray!!!
First, here is my GridColumnIndexes enum:
protected enum GridColumnIndexes : int
{
Select = 0,
Line,
Part,
GroupCode,
BackorderQuantity,
OrderDate,
PO,
OrderNumber,
OrderType,
}
The Part value is 2, so I should be indexing into the 2nd element (with an
index of 1) in ItemArray.
So, the statement:
row.ItemArray[(int)GridColumnIndexes.Part - 1] =
itemArray[(int)GridColumnIndexes.Part - 1].ToString().Substring(3);
should be the same as:
row.ItemArray[1] =
itemArray[(int)GridColumnIndexes.Part - 1].ToString().Substring(3);
but it is not.
Please look at the following image from my debugger: I am going to try to
encode an img link, but just in case, here is a link to the image:
http://www.netsplore.com/PublicPortal/Default.aspx?tabid=276
<img src='http://www.netsplore.com/PublicPortal/Default.aspx?tabid=276'>
Notice that in the watch window,
row.ItemArray[(int)GridColumnIndexes.Part - 1]
and
row.ItemArray[index]
are not accessing the same element of ItemArray even though I set index to
(int)GridColumnIndexes.Part - 1.
Anyone have any idea what is going on here?
Thanks.
no problems, but I sure can't here.
I have some code that is indexing into the ItemArray in a DataSet's DataRow.
I basically want to change the value of the data stored at a particular
index in the ItemArray. Ideally, I would like for my code to look like this
(pay attention to the index of ItemArray):
row.ItemArray[(int)GridColumnIndexes.Part - 1] =
itemArray[(int)GridColumnIndexes.Part - 1].ToString().Substring(3);
This would allow me to chop off the first 3 characters.
However, the expression (int)GridColumnIndexes.Part - 1 is not evaluating to
the correct index in the ItemArray!!!
First, here is my GridColumnIndexes enum:
protected enum GridColumnIndexes : int
{
Select = 0,
Line,
Part,
GroupCode,
BackorderQuantity,
OrderDate,
PO,
OrderNumber,
OrderType,
}
The Part value is 2, so I should be indexing into the 2nd element (with an
index of 1) in ItemArray.
So, the statement:
row.ItemArray[(int)GridColumnIndexes.Part - 1] =
itemArray[(int)GridColumnIndexes.Part - 1].ToString().Substring(3);
should be the same as:
row.ItemArray[1] =
itemArray[(int)GridColumnIndexes.Part - 1].ToString().Substring(3);
but it is not.
Please look at the following image from my debugger: I am going to try to
encode an img link, but just in case, here is a link to the image:
http://www.netsplore.com/PublicPortal/Default.aspx?tabid=276
<img src='http://www.netsplore.com/PublicPortal/Default.aspx?tabid=276'>
Notice that in the watch window,
row.ItemArray[(int)GridColumnIndexes.Part - 1]
and
row.ItemArray[index]
are not accessing the same element of ItemArray even though I set index to
(int)GridColumnIndexes.Part - 1.
Anyone have any idea what is going on here?
Thanks.