开发者

data binding to html tag in asp.net

开发者 https://www.devze.com 2023-02-20 10:56 出处:网络
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:

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

精彩评论

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