在一个asp.net控制的样式属性使用的DataBinder.Eval() [英] Using DataBinder.Eval() in style attribute of an asp.net control
本文介绍了在一个asp.net控制的样式属性使用的DataBinder.Eval()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这使得多个链接按钮asp.net Repeater控件内部的asp.net的LinkButton。我想设置每个款式,每个动态LinkButton的。
I've a asp.net linkbutton inside asp.net repeater control which renders multiple link buttons. I want to set the style of each and every linkbutton dynamically.
我试图
style="color:#6D7B8D;font-size:<%# DataBinder.Eval(Container.DataItem, "Title")%>;"
但我发现了服务器标签格式不正确的错误。
But i'm getting "The server tag is not well formed" error.
任何想法?
推荐答案
我的理解是,使用服务器标签属性要求服务器标签可用于在全部属性值。尝试改变这样:
My understanding is that using server tags for attributes requires that the server tag be used for the entire attribute value. Try changing it to this:
style='<%# "color:#6D7B8D;font-size:" + DataBinder.Eval(Container.DataItem, "Title") + ";" %>'
注意如何整个样式属性在服务器标签之间的C#code正在建设中。
Notice how the entire style attribute is being constructed in C# code between the server tags.
这篇关于在一个asp.net控制的样式属性使用的DataBinder.Eval()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文