Concatenate two or more strings in inline code ASP.NET

BumbleBee picture BumbleBee · Oct 6, 2011 · Viewed 26.2k times · Source

I am trying to place a * next to the name based on a condition.

My code :

 <asp:Label ID="lblOne" runat="server"   Text= '<%# Eval("name") + ((Eval("StatusId").Equals(0) && Eval("assignfilename") == null) ? " *" : "") %>' > </asp:Label>

Thanks

BB

Answer

Gellie Ann picture Gellie Ann · Feb 6, 2014

I'm not really familiar with in-line codes and your code seems to be a bit complicated. But I also need to concatenate an Eval("record") and a text. So to answer the question on how to concatenate, ampersand worked for me.

'<%# Eval("name") & " *" %>'

hope this helps anyone.