Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Html Helper extension
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Titre:
Html Helper extension
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01597009
Message ID:
01597009
Vues:
42
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);
        }
}
}
Regards,
Peter J. Kane



Pete
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform