17 January 2014

How to change panel color in gridview TemplateField using Eval



<asp:GridView ID="GridView1" ShowHeader="false" AutoGenerateColumns="false" runat="server">
 <Columns>
 <asp:TemplateField>
 <ItemTemplate>
 <asp:Panel ID="pnl1" runat="server" BackColor='<%# (Eval("Status").ToString() != "0" ? System.Drawing.Color.LavenderBlush : System.Drawing.Color.White)%>'>
 <div style="width: 1000px;">
 <table>
 <tr>
 <td style="width: 600px;">
 <%# Eval("Subject")%>
 -
 <%# Eval("Message")%>
 </td>
 <td style="width: 300px;">
 <%# Eval("Date")%>
 </td>
 </tr>
 </table>
 </div>
 </asp:Panel>
 </ItemTemplate>
 </asp:TemplateField>
 </Columns>
 </asp:GridView>

No comments:

Post a Comment