20 August 2013

ASP.NET GridView And Conditional Images

 
 <asp:GridView ID="GridView1" runat="server" HeaderStyle-BackColor="#b3e7ff" AlternatingRowStyle-BackColor="#dff8ff"
                        AutoGenerateColumns="false">
                        <Columns>
                            <asp:TemplateField HeaderText="Approval Status">
                                <ItemTemplate>
                                    <asp:Image ID="ApprovalImage" runat="server" ImageUrl='<%# "~/Images/" + (((bool)Eval("IsApproved") == false) ? "Unapproved.gif" : "Approved.gif") %>' />
                                </ItemTemplate>
                                <ItemStyle Width="25px" />
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>

No comments:

Post a Comment