ItemDataBound
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>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)