Click here to Skip to main content
15,921,542 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi anyone.

I have a big problem and so make me angry.

I have a table in my database with field. The fields value is a hex color Like:
#FF00FF. I create a datalistView and binding it. In three way i come to fill a div:
1. Use Style in div:
style="background-Color=<%# Eval("fieldColor") %>"

It's not work. :(
2. Use from panel and binding BackColor property:
<asp:Panel ID="Panel1" Width="25px" Height="25px"  BackColor='&lt;%# Eval("fieldColor") %&gt;' BorderStyle="Dashed" BorderColor='&lt;%# Eval("cBorder") %&gt;' runat="server">

It's not work too. :((
After a lot of searching i find this code:
3. Use Converters:
>BackColor='&lt;%# System.Drawing.ColorTranslator.FromHtml("Eval('cFi  ll')") %&gt;'


Oh no. It's not work again. :mad:

Thanks for your help.
Posted
Updated 5-Mar-11 20:35pm
v4

Use

<div style="background-color:<%# Eval("color") %>">

Not background-color= but background-color:

Note: Don't say emergency. It is not emergency for any one here. Nobody is compelled to help you here. So try to be polite.
 
Share this answer
 
oh oh. excuse me. i make mistake in language. Im not a English person. i know that but just i want u know, it's from my bad language. I am not polite. It's emergency for me. :((
Thanks from your help. I have to work and practice in my language.
 
Share this answer
 
Comments
Albin Abel 6-Mar-11 2:40am    
Thanks for revise your question. Is your problem solved finally?
texaz2 6-Mar-11 2:47am    
Sure. I use ' ' on binding. '<%# Eval("color") %>'. I saw your code and understand what is my problem. Thanks

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