Tham khảo cách Thêm thẻ html
public static MvcHtmlString CheckBoxListFor < TModel , TProperty >( this HtmlHelper < TModel > htmlHelper , Expression < Func < TModel , IEnumerable < TProperty >>> expression , IEnumerable < SelectListItem > multiSelectList , Object htmlAttributes = null ) { // Derive property name for checkbox name var body = expression . Body as MemberExpression ; if ( body == null ) return null ; String propertyName = body . Member . Name ; // Get currently select values from the ViewData model IEnumerable < TProperty > list = expression . Compile (). Invoke ( htmlHelper . ViewData . Model ); // Convert selected value list to a List<String> for easy manipulation var selectedValues = new List < String >(); if ( list != null ) selectedValues = new List < TProperty >( list ). ConvertAll ( i => i . ToString ()); // C