I have a method in my class that takes a bool and returns a string so that the user doesn't see true or false in the view. I am then trying to use this method in the MVCcontrib grid
public string BidStatusText(bool status)
{
if (status == true)
return "Bid Confirmed";
else if (status == false)
return "Bid Denied";
else
return "Bid Pending";
}
View
<%= Html.Pager((IPagination)Model) %>
<% Html.Grid(Model)
.Columns( column => {
column.For(x => x.BidText).Named("Bid Details").Sortable(false).Action(a => {%>
<td>
<%= Html.ActionLink(a.BidText, "Details", new {id = a.BidID})%>
</td>
<% });
column.For(x => x.Sector.SectorName).Named("Sector").Sortable(false);
column.For(x => x.Resource.ResourceName).Named("Resource Requested").Sortable(false);
column.For(x => x.DateStart).Named("Start Date/Time").Format("{0:dd/MM/yyyy HH:mm}");
column.For(x => x.DateEnd).Named("End Date/Time").Format("{0:dd/MM/yyyy HH:mm}");
column.For(x => x.BidStatusText(x.Status)).Sortable(false);
}).RowStart((p,row) => {
if (row.IsAlternate) { %>
<tr class="alt">
<% } else { %>
<tr>
<% }
})
.Sort((GridSortOptions)ViewData["sort"])
.Render(); %>
Error i get is
Cannot convert lambda expression to type 'string' because it is not a delegate type
public ActionResult Index(GridSortOptions sort, int? page)
{
var bids = bidRepo.GetUpcomingBids();
if (sort.Column != null)
bids = bids.OrderBy(sort.Column, sort.Direction);
ViewData["sort"] = sort;
return View(bids.AsPagination(page ?? 1, 15));
}