ASP.NET Gridview and Conditioanl Image

Depending upon a value in the data source, we can conditionally display images in GridView columns. For example, the following TemplateField declaration conditionally displays approved.gif or unapproved.gif based on IsApproved flag in the DataSet that the GridView is bound to:
<asp:TemplateField HeaderText="Yes">
                         <asp:Image ID="ApprovalImage" Height="20px" Width="20px" runat="server" ImageUrl='<%# "~/Images/" + ((Eval("U_Yeah").ToString()== "Y") ? "apply.png" : "del.jpg") %>' />

No comments:

Post a Comment