开发者

data binding to html tag in asp.net

I was just wondering if it is possible to bind data using DataBinder.Eval on a html tag with runat=server attribute. For example i want to do something like:

<a href=<%#DataBinder.Eval(Container.DataItem, "file_name") %> runat="se开发者_开发知识库rver" />

but it doesn't work. does this mean i have to use the asp.net hyperlink control?

Cheers,

Stephen


try this instead:

<a href='<%#Eval("file_name") %>' >Link text goes here...</a>


It works if the element is inside a bindable control, like a DataList or a GridView, and you don't need server control:

<a href='<%# Eval("file_name") %>' />
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜