Exemple #1
0
        public string Render(string id)
        {
            if (Options == null)
            {
                Options = new CheckBoxListOptions();
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format("<table id=\"{0}\"{1}>", id, GetClassAttribute()));
            int i = 0;

            if (Items != null && Items.Count() > 0)
            {
                foreach (CheckBoxListItem li in Items)
                {
                    if (i % Options.ItemsPerRow == 0)
                    {
                        if (i > 0)
                        {
                            sb.AppendLine("</tr>");
                        }
                        sb.AppendLine("<tr>");
                    }
                    string list_item_id = id + "_" + i.ToString();
                    li.Disabled = Options.ReadOnly;
                    sb.AppendLine(li.Render(list_item_id));
                    i++;
                }
                while (i % Options.ItemsPerRow > 0)
                {
                    sb.AppendLine("<td>&nbsp;</td>");
                    i++;
                }
            }
            else
            {
                sb.AppendLine("<tr>");
                sb.AppendLine("<td class=\"nodata\">" + Options.NoItemsText + "</td>");
            }
            sb.AppendLine("</tr>");
            sb.AppendLine("</table>");

            return(sb.ToString());
        }
Exemple #2
0
 public CheckBoxList(IEnumerable <CheckBoxListItem> items = null, CheckBoxListOptions options = null)
 {
     Items   = items;
     Options = options;
 }