Click here to Skip to main content
16,018,529 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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.
Posted
Comments
Sergey Alexandrovich Kryukov 27-Jun-12 12:02pm    
Not a question, and not clear. If you need knowledge, learn it.
--SA

In the ItemDataBound event of the datalist, add below code, see if it works:

C#
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.
}
 
Share this answer
 
Try:
HTML
<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>
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900