Test Menu

  • Commentary
  • Deals
  • Coupons

Nov 28, 2011

Concatenating Static Text to an Eval Expression

This wasn't obvious to me even though it seemed basic.  Full credit goes to the original post on stackoverflow.

I was using a datalist and wanted to concatenate the text "Collection Type: " before the Eval expression.  The only solution I could find was to use a format string.  I favored this solution instead of using the code-behind.

<asp:Label ID="CollectionTypeLabel" runat="server" text='<%#DataBinder.Eval(Container.DataItem, "CollectionType", "Collection Type: {0}")%>' />

No comments:

Post a Comment