private static void RenderDropDown(HtmlWriter writer, IEnumerable<GridCell> cells, GridCell selectedCell, IEnumerable<int> validOptions) { writer.RenderBeginTag(HtmlTextWriterTag.Select); writer.AddAttribute("value", ""); if (selectedCell == null) writer.AddAttribute("selected","selected"); writer.RenderFullTag(HtmlTextWriterTag.Option, "None"); foreach (var cell in cells.Where(c => c.ColumnSpan >= validOptions.Min())) { writer.AddAttribute(HtmlTextWriterAttribute.Value, cell.Key); if (cell == selectedCell) writer.AddAttribute("selected", "selected"); writer.RenderFullTag(HtmlTextWriterTag.Option, cell.Key); } writer.RenderEndTag(); }
public GridCell AddCell(int columnSpan, string key, string displayName, GridLayoutCellType type) { var totalSpan = _cells.Select(c => c.ColumnSpan).Sum() + columnSpan; if (totalSpan > _layout.ColumnSpan) throw new ArgumentException("Cannot add cell, as the combined row span would be larger than " + _layout.ColumnSpan); var cell = new GridCell(columnSpan, key, displayName, type); _cells.Add(cell); return cell; }