I need some help creating this extension method.
My view inherits from
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/NoSideMenu.Master"
Inherits="System.Web.Mvc.ViewPage<List<MyProject.Models.Customer>>" %>
And I have a grid control defined by
<% Html.Telerik().Grid(Model)
.Name("customer-history-grid").Footer(false).Columns(columns =>
{
columns.Bound(o => o.IsValidCustomer).Title(Html.Resource("ValidCustomerTableHeader"));
}
).Pageable(pager => pager.PageSize(25))
.Footer(true)
.Render();
%>
Here I don’t want to display the boolean value. Instead I want to display Y or N. For example if o.IsValidCustomer is true then Y else N.
I tried writing the below extension method
public static string ConvertToString<T, TValue>(this HtmlHelper<T> helper, Expression<Func<T, TValue>> expression)
{
......
}
But my extension method picks up the List<MyProject.Models.Customer> type and not the Customer object. So I cannot select the method o.IsValidCustomer in the lambda expression for example
in View…
columns.Bound(o => o.IsValidCustomer).Format(Html.ConvertToString(o => o.IsValidCustomer)).Title(Html.Resource("ValidCustomerTableHeader"));
Would it be possible to edit your domain model?
E.g. add this
Then just bind that as a column?
HTHs,
Charles