 <p>You can use a <code>TemplateField</code>, and, inside it something like this:</p> <pre><code>&lt;asp:Image runat="server" id="myImg" ImageUrl='&lt;%# GetImage(DataBinder.Eval(Container.DataItem, "b_attach")) &gt;%' visible='&lt;%# null != DataBinder.Eval(Container.DataItem, "b_attach") %&gt; /&gt; </code></pre>