如何为数据列表中的标签编写cssclass. [英] how to write cssclass for label within datalist.
本文介绍了如何为数据列表中的标签编写cssclass.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
先生,
当我要使用jquery/json和webservice绑定数据列表时,我得到了cssclass作为标签,我必须写才能绑定数据列表.但是我没有任何知识.请帮助我.
sir,
when i am going to bind datalist using jquery/json and webservice, i got cssclass for label i have to write to bind datalist. but i have not any knowledge. plz help me.
推荐答案
在数据列表的ItemDataBound
事件中,添加以下代码,看看是否有效:
In theItemDataBound
event of the datalist, add below code, see if it works:
Label lbl= e.Item.FindControl("LblText") as Label; // lblText will be your Label control
if (lbl != null)
{
lbl.Attributes.Add("class", "LabelClass"); // LabelClass will be you CSS class name.
}
尝试:
<asp:DataList id="ItemsList"
RepeatDirection="Vertical"
RepeatLayout="Table"
RepeatColumns="0"
runat="server">
<ItemTemplate>
<asp:Label id="myLabel"
Text='<%# DataBinder.Eval(Container.DataItem, "myLabelText") %>'
CssClass = "myClass"
runat="server"/>
</ItemTemplate>
</asp:DataList>
这篇关于如何为数据列表中的标签编写cssclass.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文