Based on Model Column Value(true/False) in MVC3 Webgrid , How can Add a Link as column in diplaying the rows

I am using MVC3 Webgrid. I have model which has column of type bool. Based on the Value of this coulumn I need to render a coulmn , with hyper link. If the bool column value is true then I have to render Record, else Edit.

Could you kindly give the syntax for these in Razor .

Thank you

-------------Problems Reply------------

You can use an if statement when you create the column, like so:

grid.Column("Conditional Cell Sample", format: @<text>@if(true == true) { @Html.ActionLink("Go here", "Home") } else { @Html.ActionLink("Or here", "Away") }</text>)

Simply replace true == true with your condition, and the content of if and else to be what you need.

Ref: http://lottemae.wordpress.com/2011/11/17/using-conditional-statements-in-an-mvc-3-webgrid-column-using-razor/

Category:asp.net mvc 3 Views:0 Time:2011-07-18

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.603 (s). 11 q(s)