ASP.NET Repeater - Evaluate Item as int?
        Posted  
        
            by WedTM
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by WedTM
        
        
        
        Published on 2010-04-16T20:09:27Z
        Indexed on 
            2010/04/16
            20:13 UTC
        
        
        Read the original article
        Hit count: 318
        
I'm trying to style a table row based upon a value in the databound collection (from LINQ to SQL) in my item template, however it's not working.
This is what I have so far:
                       <ItemTemplate>
                            <% 
                                string style = String.Empty;
                                if ((string)DataBinder.Eval(Quotes.Cu, "Status") == "Rejected")
                                    style = "color:red;";
                                else if ((string)Eval("Priority") == "Y")
                                    style = "color:green;";
                                if (style == String.Empty)
                                    Response.Write("<tr>");
                                else
                                    Response.Write("<tr style=\"" + style + "\"");                            
                            %>
                            <td>
                                <%# Eval("QuoteID") %>
                            </td>
                            <td>
                                <%# Eval("DateDue", "{0:dd/MM/yyyy}") %>
                            </td>
                            <td>
                                <%# Eval("Company") %>
                            </td>
                            <td>
                                <%# Eval("Estimator") %>
                            </td>
                            <td>
                                <%# Eval("Attachments") %>
                            </td>
                            <td>
                                <%# Eval("Employee") %>
                            </td>
                            </tr>
                        </ItemTemplate>
© Stack Overflow or respective owner