title: Conditionally display an image in webgrid - mvc 3
body: <p>In my webgrid I need to display images based on the value .. Code is given below </p>
  
  <pre><code>@model TraktorumMVC.Models.ManagePhotos
  @{
      ViewBag.Title = "ManagePhotos";
      Layout = "~/Views/Shared/_Layout.cshtml";
      var grid = new WebGrid(Model.AdPhotos);
  }
  
  
      @grid.GetHtml(
         displayHeader: false,
         columns: grid.Columns(
               grid.Column(format: (item) =&gt;
                   {
                       if (item.IsMainPreview == true)
                       {
                           return @&lt;text&gt;&lt;img src="@Url.Content("~/Content/images/preview-photo.gif")" alt="Image "/&gt;&lt;/text&gt;;
                       }
                       else
                       {
                           return @&lt;text&gt;&lt;img src="@Url.Content("~/Content/images/non-preview-photo.gif")" alt="Image "/&gt;&lt;/text&gt;;
                       }
                   }
                  ),               
               grid.Column(format: (item) =&gt; Html.ActionLink("Remove Photo", "RemovePhoto", "Images", new { photoID = @item.Id }, new { @class = "RemovePhoto" }))
           ));
  </code></pre>
  
  <p>I am not sure how can i use <code>if</code> in webgrid . I just tried that .Its not working .getting following  error </p>
  
  <pre><code>The best overloaded method match for 'System.Web.Helpers.WebGrid.Column(string, string, System.Func&lt;dynamic,object&gt;, string, bool)' has some invalid arguments
  </code></pre>