Reputation: 11916
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 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(""))
Upvotes: 2
Views: 6655
Reputation: 11916
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(""))
Upvotes: 8