How to use Single Quotes in Eval Format String

前端 未结 4 1154
北海茫月
北海茫月 2020-12-11 17:20

I\'ve got a Repeater and its SqlDatasource nested inside a Gridview TemplatedField.
The Repeater\'s datasource SelectCommand is set using the FormatString of an Eval fro

4条回答
  •  庸人自扰
    2020-12-11 18:16

    Don't forget that a .aspx page is simply XML. You just escape the quotes as you normally would.

    For example:

    
        
            
        
        
            

    When the above expression is databound the value between <%# and %> becomes:

    Eval("Id", "This is item '{0}'.")

    ...which produces on the HTML page as output when databound with an array of objects with "Id" property values from 1 to 5:

    This is item '1'.
    This is item '2'.
    This is item '3'.
    This is item '4'.
    This is item '5'.

提交回复
热议问题