title: HashSet as DataSource
body: <p>I am trying to optimize the code for SharePoint webpart. I have a repeater control:</p>
  
  <pre><code>&lt;asp:Repeater ID="CountryOptionsRepeater" runat="server"&gt;
      &lt;ItemTemplate&gt;
          &lt;option value='&lt;%#Eval("CountryName") %&gt;'&gt;&lt;%#Eval("CountryName") %&gt;&lt;/option&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>I am filling it with data-table</p>
  
  <pre><code>countriesList = countriesList.Distinct&lt;String&gt;().ToList&lt;String&gt;();
  countriesList.Sort();
  //var noDupsCountriesList = new HashSet&lt;String&gt;(countriesList);
  
  DataTable dt = new DataTable();
  dt.Columns.Add("CountryName");
  
  foreach (String countryName in countriesList)
  {
      DataRow dr = dt.NewRow();
      dr["CountryName"] = countryName;
      dt.Rows.Add(dr);
  }
  
  CountryOptionsRepeater.DataSource = dt;
  CountryOptionsRepeater.DataBind();
  this.DataBind();
  </code></pre>
  
  <p>Is there a way to directly bind HashSet object (noDupsCountriesList) to DataSource with same configuration of repeater, in order to bring about optimization?</p>
  
  <p>Something like:</p>
  
  <pre><code>//countriesList = countriesList.Distinct&lt;String&gt;().ToList&lt;String&gt;();
  //countriesList.Sort();
  var noDupsCountriesList = new HashSet&lt;String&gt;(countriesList);
  
  CountryOptionsRepeater.DataMember = "CountryName"; // ??
  CountryOptionsRepeater.DataSource = noDupsCountriesList;
  CountryOptionsRepeater.DataBind();
  this.DataBind();
  </code></pre>