Concatenate text with Eval

2019-01-14 06:32发布

问题:

How to concatenate static text in the start of Eval("") in asp.net?

回答1:

try...

Text='<%# "Mr " + Eval("FirstName") + " " + Eval("LastName")%>'


回答2:

For concating two fields from db you can use string.Concat function in eval()

 Text='<%# string.Concat(Eval("FirstName"), " ", Eval("LastName"))%>'


回答3:

This works fine for me:

<%#Class.something.ToString() & Eval("something_to_eval")%>


回答4:

Doing this (without single quote) worked for me. And Visual Studio underlines it as a Validation warning.

 onclick=<%# "modCbClick('#tbl_" + Eval("ModCode") + "', this)" %>


回答5:

try this: Text='<%# string.Concat("Table No:", " ", Eval("table_no")) %>'