DataGrid: Setting row background color programatically

M

M. Craig

Does anyone have an example or suggestion as to how to programatically
databind a row's background color? I understand how to use an
asp:TemplateColumn to set the BG color on a column, but I want to
dynamically set the BG color based on a value returned from a database

I've tried the following with no success:
<ItemStyle BackColor=<%# DataBinder.Eval(Container.DataItem, "color") %>
/>

the error states that ItemStyle doesn't have a definition for DataBinder.

Help?

thanks.
 
R

Ravikanth[MVP]

Hi

Please check the following article
http://www.dotnetjunkies.com/howto/default.aspx?id=27

HTH
Ravikanth[MVP]

-----Original Message-----
Does anyone have an example or suggestion as to how to programatically
databind a row's background color? I understand how to use an
asp:TemplateColumn to set the BG color on a column, but I want to
dynamically set the BG color based on a value returned from a database

I've tried the following with no success:
<ItemStyle BackColor=<%# DataBinder.Eval
(Container.DataItem, "color") %>
 
M

M. Craig

Thanks. That looks like what I needed. I had been using the ItemDataCreated
no the ItemDataBound method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top