开发者

Web grid MVC 3- If syntax for checking a condition

I have a syntax error here, Could any one point out what is this please?

I have ViewBag.IsAdmin from the Controller

//code- I am writing this in a view-webgrid
grid.Column(format : (item) => {
                                 if(ViewBag.isAdmin)
                                  {

                                          Html.ActionLink("Edit", "EditSingleAbsence","Absence", new { AbsenceId = item.id }, null);
                                  }
                               }
          )    
/code ended

It compalines with this error:

  CS1502: The best overloaded method match for 'System.Web.Helpers.WebGrid.Column(string, string, System.Func<dynamic,object>, string, bool)' has some invalid arguments

I have开发者_如何学Python found answer from here

Here Solution

No Need to use if condition..

grid.Column(format:(item) => ViewBag.isAdmin ? Html.ActionLink("Edit", "EditSingleAbsence", "Absence", new { AbsenceId = item.id }, null) : Html.Raw("")) 


Working Solution

after Googling this worked for me. I got this solution from Here

grid.Column(format:(item) => ViewBag.isAdmin ? Html.ActionLink("Edit", "EditSingleAbsence", "Absence", new { AbsenceId = item.id }, null) : Html.Raw("")) 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜