Hi,
I'd like to create a sequence column in my datatable. I have already placed a "1" at [0][0], and then use the following :-
The value in "column" DtSet.Tables[0].Rows[i][7] is a seven digit number.
The above code works, but I was wondering if there was a way to streamline it?
Thanks in advance.
I'd like to create a sequence column in my datatable. I have already placed a "1" at [0][0], and then use the following :-
int SeqNum = Convert.ToInt32(DtSet.Tables[0].Rows[0][0]); for (int i = 0; i < DtSet.Tables[0].Rows.Count-1; i++) { string a1 = DtSet.Tables[0].Rows[i][7].ToString(); string a2 = DtSet.Tables[0].Rows[i+1][7].ToString(); if (a1 != a2) { DtSet.Tables[0].Rows[i][0] = SeqNum++; } else DtSet.Tables[0].Rows[i][0] = SeqNum; }
The value in "column" DtSet.Tables[0].Rows[i][7] is a seven digit number.
The above code works, but I was wondering if there was a way to streamline it?
Thanks in advance.