开发者

Concatenate text with Eval

开发者 https://www.devze.com 2023-02-12 21:32 出处:网络
How to concatenate static 开发者_如何转开发text in the start of Eval(\"\") in asp.net?try... Text=\'<%# \"Mr \" + Eval(\"FirstName\") + \" \" + Eval(\"LastName\")%>\'

How to concatenate static 开发者_如何转开发text in the start of Eval("") in asp.net?


try...

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


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

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


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


This works fine for me:

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


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

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


Here is a good method I am using whereby I want to Concatenate a string to an Eval and use in the CommandArgument of a LinkButton.

Append string to start

CommandArgument='<%# String.Format(string.Concat("TextString", Eval("DBValue")))%>'

Append string to end

CommandArgument='<%# String.Format(string.Concat(Eval("DBValue"), "TextString"))%>'
0

精彩评论

暂无评论...
验证码 换一张
取 消