开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜