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

Is it possible to change the color of a row in data table depending on text values before binding it to the grid? I can change the row color in grid but I want to know whether is there any way that it can done in data table itself. If so, please let me on how to achieve that.

Thanks in advance..
Posted

Well, you are able to do the row color functionality in Datagrid as it is supported by Datagrid. If you have a look at the rendered HTML of a datagrid, it is a table with additional html defining the style of rows if defined.
Hope this explains you that the similar thing is not supported inherintly in Tables.

Further, though you can explicitly try to add style to each row of table but while binding it to a grid, it would not integrate those table row sytles and thus it would be futile to do so. You will have to go and add row styles in grid.
 
Share this answer
 
Comments
NishaPai 10-Jul-10 5:07am    
Thanks for the explanation Sandeep. Can you let me know how to see the rendered html of a grid?
Sandeep Mewara 10-Jul-10 5:09am    
Just do a ViewSource of the page in browser where you have a Gridview. :)
NishaPai 10-Jul-10 5:32am    
How dumb I am!! I knew this but didn't flash when I read it in your answer.. Anyways Thanks for taking time to answer such a silly question :)
Sandeep Mewara 10-Jul-10 7:15am    
No issues! :)
Maybe this post can help.
 
Share this answer
 
Comments
NishaPai 10-Jul-10 5:41am    
Thanks for the link Abhinav, but What is in the link is changing the row color of grid which I have already done. What I want is, changing it in the dynamically binding data table before binding it to the grid. According to Sandeep's answer, I assume its not possible but Please feel free to share if you have any other suggestions :)

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