public static IHtmlString CheckBoxList <T>(this HtmlHelper helper, string name, IEnumerable <T> items, Expression <Func <T, object> > valueExpression, Expression <Func <T, object> > textExpression, CheckBoxListOptions options = null) { List <CheckBoxListItem> cbliList = new List <CheckBoxListItem>(); foreach (T item in items) { CheckBoxListItem cbli = new CheckBoxListItem { Value = valueExpression.Compile().Invoke(item).ToString(), Text = textExpression.Compile().Invoke(item).ToString() }; cbliList.Add(cbli); } CheckBoxList cbl = new CheckBoxList(cbliList, options); return(new HtmlString(cbl.Render(name))); }
public static IHtmlString CheckBoxList(this HtmlHelper helper, string name, IEnumerable <CheckBoxListItem> items = null, CheckBoxListOptions options = null) { CheckBoxList cbl = new CheckBoxList(items, options); return(new HtmlString(cbl.Render(name))); }