1
votes

I have a datatable with 3 columns( col1,col2,col3) I have added an extra column with col4(Lets say).

Now My requirement is :

Col1 ||    col2 ||  col3  ||  col4

A          B        C         Col1-A;Col2-B;Col3-C 

Basically, I want a concatenated values in the new column of the existing column name and values as demonstrated above. Hope my requirement is understood. Thanks in Advance!

1
If you know how to insert and retrieve values you can basically do a String.Format("Col1-{0};Col2-{1};Col3-C{2}", Col1Val, Col2Val, Col3Val); and insert it's value in Col4 - Corstian Boerman

1 Answers

2
votes

This might do the trick for you

DataColumn newColumn;
newColumn = new DataColumn("col4");
newColumn.Expression =  string.Format("Col1\-{0};Col2\-{1};Col3\-{2}", col1, col2, col3);
scaleResponseData.Columns.Add(newColumn);