private static string BuildCheckBox(string name, IDictionary <string, object> checkboxHtmlAttributes, bool readOnly, SpecialSelectListItem item) { string output = ""; output = "<div class='fields'><label>"; var checkboxList = new TagBuilder("input"); checkboxList.MergeAttribute("type", "checkbox"); checkboxList.MergeAttribute("name", name); checkboxList.MergeAttribute("value", item.Value); if (readOnly) { checkboxList.MergeAttribute("disabled", "disabled"); } // Check to see if it's checked if (item.Selected) { checkboxList.MergeAttribute("checked", "checked"); } // Add any attributes if (checkboxHtmlAttributes != null) { checkboxList.MergeAttributes(checkboxHtmlAttributes); } checkboxList.SetInnerText(item.Text); output += checkboxList.ToString(TagRenderMode.SelfClosing); output += " " + item.Text + "</label></div>"; return(output); }
private static string BuidOption(IDictionary <string, object> checkboxHtmlAttributes, bool readOnly, SpecialSelectListItem item) { string output = ""; var option = new TagBuilder("option"); option.MergeAttribute("value", item.Value); option.SetInnerText(item.Text); if (readOnly) { option.MergeAttribute("disabled", "disabled"); } // Check to see if it's checked if (item.Selected) { option.MergeAttribute("selected", "selected"); } // Add any attributes //if (checkboxHtmlAttributes != null) // option.MergeAttributes(checkboxHtmlAttributes); output += option.ToString(TagRenderMode.Normal); return(output); }
private static IEnumerable <SpecialSelectListItem> GetChidItems(IEnumerable <SpecialSelectListItem> items, SpecialSelectListItem parentItem) { return(items.Where(o => o.ParentId == int.Parse(parentItem.Value)).OrderBy(o => o.Order)); }