I've a DataTable and have two columns 'FirstName' and 'LastName'.
I've created a datacolumn to concat value from these two columns. Here is my code -
DataColumn fullname = dt.Columns.Add("Full Name");
string fn = string.Format(string.Concat("'First Name - '+", "{0}", "+ ';<br />"), "FN");
string ln = string.Format(string.Concat("Last Name - '+", "{0}", "+ ';<br />"), "LN");
otherDetails.Expression = string.Concat(fn, ln);
The code is working fine and concatenates values from two fields. But if any of the column value is null then the expression is not working and is returning as empty.
For example for the 5th record is if first name is 'Tim' and the second name is null the I want the value to be displayed as 'Tim'. But instead for that record the value of this expression column is empty.
Any ideas?
string.Concat(null, "2")will return "2", not an empty string or a null value. Could you give more "real" code ? - Raphaël Althaus