Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Html Helper extension
Message
From
21/03/2014 08:00:36
 
General information
Forum:
ASP.NET
Category:
MVC
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01597009
Message ID:
01597022
Views:
32
What version of MVC are you using?

>Hi All, I downloaded some code that is supposed to extend the Html helpers to enable an Enum to be used as the datasource for a Dropdownlist, but I'm getting a compiler error of and I can't figure it out
>
>
>Inconsistent accessibility: parameter type 'System.Linq.Expressions.Expression<BusinessLayer.Func<TModel,TProperty>>' 
>is less accessible than method 'BusinessLayer.Extension.EnumDropDownListFor<TModel,TProperty,TEnum>
>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<BusinessLayer.Func<TModel,TProperty>>, TEnum)'
>
>
>
>
>namespace BusinessLayer
>{
>public static class Extension
>    {
>public static MvcHtmlString EnumDropDownListFor<TModel, TProperty, TEnum>(
>                    this HtmlHelper<TModel> htmlHelper,
>                    Expression<Func<TModel, TProperty>> expression,
>                    TEnum selectedValue)
>        {
>            IEnumerable<TEnum> values = System.Enum.GetValues(typeof(TEnum))
>                                        .Cast<TEnum>();
>
>            IEnumerable<SelectListItem> items = from value in values
>                                                select new SelectListItem()
>                                                {
>                                                    Text = value.ToString(),
>                                                    Value = value.ToString(),
>                                                    Selected = (value.Equals(selectedValue))
>                                                };
>           
>            return SelectExtensions.DropDownListFor(htmlHelper, expression,items);
>        }
>}
>}
>
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Reply
Map
View

Click here to load this message in the networking platform