开发者

ASP.NET Databinding Template: Escape Tags in a Server Tag

开发者 https://www.devze.com 2022-12-18 13:32 出处:网络
I\'m doing some databinding inside a ListView ItemTemplate, but I suspect this is a problem for any databinding/template situation.I want to writ开发者_运维百科e something like:

I'm doing some databinding inside a ListView ItemTemplate, but I suspect this is a problem for any databinding/template situation. I want to writ开发者_运维百科e something like:

<asp:HiddenField runat="server" ID="hidPositionID" Value="<%#Eval("PositionID") %>" />

But I get a YSOD with an error message that the server tag is not well formed. How do I persist non-visible data inside my ListViewItem?

Thanks!


Use single quotes ('') to wrap anything with "" inside the value so the start/stop pairs match:

<asp:HiddenField runat="server" 
                 ID="hidPositionID" 
                 Value='<%#Eval("PositionID") %>' />
0

精彩评论

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