asp.net mvc 3 - trying to create a dynamic link in MVC 3 -


I am working on my company intranet site, on a page I need to include a link to PDF files They exist There is no problem, I got it to work well. If there is a problem I am changing the link if the PDF is not present. Here's what I currently do:

 , grid.Column (format: (item) => (File.Exists (item.FileName) == True @ & lt; a href = "@? Url.Content (item.FileName)" & gt; Art work & lt; / a & gt;: Html.Raw (""))   

I get errors I'm: Logic 3: Can not change 'System.Func'

'Lambda Expression' and 'System.Web.Helpers.WebGrid.Column (string, string, System.Func, string, bool) The best overloaded method is to match some invalid arguments

I have worked hard with Google and nothing Get what someone tells me where I am wrong?

I will definitely write a custom assistant who is responsible for generating the appropriate link: HtmlExtensions {public static IHtmlString LinkToFile Var file = htmlHelper.ViewContext.HttpContext.Server.MapPath (filename); If (file! Example (file)) {return MvcHtmlString.Empty; } Var Anchor = New Tag Builder ("a"); Anchor. Attribute ["href"] = urlHelper.Content (filename); Anchor.SetInnerText ("Art work"); Return the new HtmlString (anchor.ToString ()); }}

and then use this assistant just inside:

  grid.Column (format: @ & lt; text & gt; @ Html.LinkToFile ((string) item.FileName) )    

Comments