Saad Suri Saad Suri - 5 months ago 18
SQL Question

Use asp.net label for a css class name

I want to use a label value for a css class name.

I am getting a label value from database through Eval and want to use it for a css class name

Here is what I am doing

<span class="<asp:Label ID="lbl_icon" runat="server" Text='<%# Eval("icon")%>'></asp:Label>"></span>


but I'm not getting the result which i want.

Answer

There isn't any need to use a Label control there. You could just try the following:

<span class='<%# Eval("icon")%>'></span>