Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic CssClass in a BoundField

Status
Not open for further replies.

JLizOB

Programmer
Dec 5, 2007
45
CA
Hi I have a Gridview with some boundfields. I want to dynamically change the color of text based on the datafield value for each row. Is there anyway to do this as a boundfield or do I have to turn it into a template field? Below is a snippet:
Code:
<asp:BoundField HtmlEncode="False" DataFormatString="{0:$#,##0;($#,##0)}" DataField="Remaining" SortExpression="Remaining" HeaderText="Remaining">
<ItemStyle CssClass="" HorizontalAlign="Right"></ItemStyle>
 
Take a look at the RowDataBound event of the gridview. In there you will be able to change the css.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top