Gridview edit ItemTemplate RRS feed

  • Question

  • Hi, I have an ItemTemplate that gets a numeric value from <%# Bind("Retard") %>. If the value is negative I want the background to be Red, is positive I want the background to be Green. The data source is a DataTable, I dont want to loop the DataTable and write the HTML, I would like to know if I can do it inside the GridView, is it possible?

    <asp:TemplateField HeaderText="Retard" SortExpression="Retard">
            <asp:Label ID="Label1" runat="server" Text='<%# Bind("Retard") %>'></asp:Label>

    Example, the background color of the cells should be red or green:


    • Edited by renatois Monday, November 18, 2013 9:38 AM
    Monday, November 18, 2013 8:58 AM