none
How can i copy the data from one datacolumn to another in the same datatable in an optimized way.

    Question

  •  

    Hi All,

     

    I have a requirement where i need to copy the data from one datacolumn to another datacolumn in the same datatable.   How can i accomplish this in an optimized way without looping the rows ?

    Monday, December 01, 2008 6:28 AM

Answers

  • You can create computed column with expression set to the value of original column. It’s not clear to me why can’t you just use original column though.

     

    Monday, December 01, 2008 7:26 AM

All replies

  • You can create computed column with expression set to the value of original column. It’s not clear to me why can’t you just use original column though.

     

    Monday, December 01, 2008 7:26 AM
  • Hi,

     

    I can't use the original column.  As i have to show original column(say COL1) value to user and the another datacolumn(say DUMMY) is for technical calcuations which will be changed after performing business validations on each input of the user.

     

    I can't put my entire business validation into the expression of the computed column(DUMMY).    I also have the requirement where i need to show business validated data(DUMMY column data) in to the original column(COL1) and the user can modify the values and viceversa.

     

    So, is using computed column with expression set is the only option ?

    Monday, December 01, 2008 7:55 AM
  • Add a temporary column in Table 

    dt.Columns.Add("Temp");

    dt.Columns["Temp"].Expression = "OriginalColumn+ ';' ";  //I am appending ";" to the original values



    Thanks
    Savan

    savan
    Friday, February 13, 2009 12:32 PM