Developer forum

Forum » Templates » How to substract certain text from a column value

How to substract certain text from a column value


Reply
While playing around with Datalists I seem to have hit a stumbling block. It is probably quite simple to solve, but I dont see how unfortunately.

I want to show the Column Name, but the system-name that is provided, that includes the name of the table, is not good enough for me.

Example:
http://lbr.net.dynamicweb.dk/Default.aspx?ID=346

Instead of "Tilmeldingsformular_Navn" I want it to show just "Navn".


My hope was, that there was another tag, like Column.Label or something similar that could be used, but this doesn't seem to be the case. I have also tried various combinations, in my attempt to subtract the tekst "Tilmeldingsformular_" from the output, but nothing quite does it for me.

For example I tried this (which seemed to easy, so I didn't expect it to work either):

xsl:value-of select="Column.Name - 'Tilmeldingsformular_'"

This outputs the value "NaN" and not what I want.


Of course, I could hardcode the column-names, but I want to avoid this, because the number of columns will increase and also change, so I want it to be as flexible and without me having to edit my hardcoded column-names all the time.

Replies

 
Reply
Hi Lars

In this case where you only want to use a part of a string (Tilmeldingsformular_Navn).
You could do like this:
<xsl:value-of select="substring('Tilmeldingsformular_Navn', 20, 24)" />

If the string is available in a node(Field.SystemName) you can do like this:
<xsl:value-of select="substring(Field.SystemName, 20, string-length(Field.SystemName))" />
 
Reply
Nice, Exactly what I was looking for! Thanks!
 
Reply
You could also check out the functions called 'substring-before' and 'substring-after'.

 

You must be logged in to post in the forum