Hi,
I have formatted the below formula in sharepoint calculated field thru dibrary settings which is working fine.
=""&Title&""
The above formulla I am trying to do thru code behind, for that i have just replaced the & with + then the formula looks like below:
SPFieldCalculated totalMiles = currentlist.Fields.GetFieldByInternalName("CustomCalcField") as SPFieldCalculated;
totalMiles.Formula ="="+Title+""
Note: ItemID and ListID I have calculated thru programatically.
But its not working, throwing exception "the formula contains a syntax error or is not supported". Any help would be appreciated.
Loading
Brijendra GautamPosted Mar 16, 2014, 11:32 PM
You need to pass the anchor tag as a string in double quot( " ). Since you are generating a single line of text then the formula should contains only strings.
SPFieldCalculated totalMiles = currentlist.Fields.GetFieldByInternalName("CustomCalcField") as SPFieldCalculated;
totalMiles.Formula ="=\"\""+Title+"\"\"";
But this way also it will display all the html into your column and will not generate hyperlink. If want it to be displayed as a link then use custom web parts or display it in XSLT.