title: Dynamically Create A Color Legend Based off of a collection
body: <p>I am trying to create a legend based on a collection,the code below goes into a Shapefile and pulls specific column data then we assign a color to the data. this i made within the controller and i was wondering if i can create an HTML legend based of of this collection, the way im thinking of doing it is creating radio buttons with each of the layers that we want legends for. i Know this may be vague but i dont really know how to describe it.</p>
  
  <p>any suggestions will be greatly appreciated </p>
  
  <pre><code> private Collection&lt;ValueItem&gt; colorSelect(Collection&lt;Feature&gt; allFeatures, string layercode,Collection&lt;ValueItem&gt; valueItems)
      {
  
          List&lt;string&gt; values = new List&lt;string&gt;();
          foreach (Feature f in allFeatures)
          {
              if (f.ColumnValues.ContainsKey(layercode))
              {
                  if (!values.Contains(f.ColumnValues[layercode].ToString()))
                  {
                      values.Add(f.ColumnValues[layercode].ToString());
                  }
              }
  
          }
  
  
          if (values.Count &gt; 0)
          {
              Random randomGen = new Random();
              int count = 0;
              foreach (string esnCode in values)
              {
                  //int count = 0;
                  if (count == 0)
                  {
                      ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Green, GeoColor.StandardColors.Black, 3));
                      valueItems.Add(item);
  
                  }
                  if (count == 1)
                  {
                      ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Pink, GeoColor.StandardColors.Black, 3));
                      valueItems.Add(item);
  
                  }
                  if (count == 2)
                  {
                      ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Blue, GeoColor.StandardColors.Black, 3));
                      valueItems.Add(item);
  
                  }
                  if (count == 3)
                  {
                      ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Yellow, GeoColor.StandardColors.Black, 3));
                      valueItems.Add(item);
  
                  }
                  if (count == 4)
                  {
                      ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Violet, GeoColor.StandardColors.Black, 3));
                      valueItems.Add(item);
  
                  }
                  if (count == 5)
                  {
                      ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Red, GeoColor.StandardColors.Black, 3));
                      valueItems.Add(item);
  
                  }
                  if (count == 6)
                  {
                      ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Aqua, GeoColor.StandardColors.Black, 3));
                      valueItems.Add(item);
  
                  }
                  if (count == 7)
                  {
                      ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Black, GeoColor.StandardColors.Black, 3));
                      valueItems.Add(item);
  
                  }
                  if (count == 8)
                  {
                      ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Brown, GeoColor.StandardColors.Black, 3));
                      valueItems.Add(item);
  
                  }
                  if (count == 9)
                  {
                      ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Coral, GeoColor.StandardColors.Black, 3));
                      valueItems.Add(item);
  
                  }
                  if (count == 10)
                  {
                      ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.DarkKhaki, GeoColor.StandardColors.Black, 3));
                      valueItems.Add(item);
  
                  }
                  count++;
              }
  
          }
          return (valueItems);
      }
  </code></pre>