Question

I am using the MVCContrib grid and I would like to display images depending on the values of a column, e.g.:

  • if the column's value is null display the image "<img src="true.gif">"
  • otherwise display the image "<img src="false.gif">

Furthermore I would also need (this should be the same approeach I think) to display different actions depending on the column's/rows' value ...

Thanks in advance for your answers!

Best regards
Stefan

Was it helpful?

Solution

The answer was quite simple :)

<% Html.Grid(Model.Languages).Columns(column =>
       {
           column.For(c => c.LanguageName).Named("Language");
           column.For(c => c.LangCode).Named("Language Code");
           column.For(c => c.IsDefaultLanguage ? "<img src=\"library/images/true.gif\">" : "<img src=\"library/images/false.gif\">").Named("Default Language").DoNotEncode();
       }

       ).Empty("There is no language available")
        .Render(); %>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top