Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to concat the value of different columns to a single column in the same datatable.

but some column cell value is null. In that case this is not working.

Any idea?

What I have tried:

I have tried the below
DataColumn totalColumn = new DataColumn();
totalColumn.DataType = System.Type.GetType("System.Object");
totalColumn.ColumnName = "FullString";

totalColumn.Expression ="COLUMN1+COLUMN2".

it works if all the cell contains data.

but if any cell went to null this will not work.
Posted
Updated 1-Mar-16 20:46pm
Comments
Sinisa Hajnal 2-Mar-16 2:23am    
Ensure that during binding you don't have nulls, have defaults instead.

1 solution

You can use the below code to resolve your problem:

C#
totalColumn.Expression = "ISNULL(COLUMN1, '')+ISNULL(COLUMN2, '')";



Thanks,
 
Share this answer
 
Comments
Indukanth 2-Mar-16 4:45am    
thankyouu.. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900