title: Binding a Dictionary<string, string> to a DataList
body: <p>I have a Dictionary (let's call it info) that I am trying to bind to a DataList (we'll call it directory). The dictionary is declared as follows:</p>
  
  <pre><code>    Dictionary&lt;string, string&gt; info = new Dictionary&lt;string, string&gt;(){
         {"AdvertisementID", "1"},
         {"CompanyName", "Test"},
         //More elements
        };
  </code></pre>
  
  <p>Now, I bind the Dictionary to the DataList as follows:</p>
  
  <pre><code>    directory.DataSource = info;
      directory.DataBind();
  </code></pre>
  
  <p>My asp code looks like this:</p>
  
  <pre><code>    &lt;asp:DataList ID = "directory" runat="server" RepeatColums="3" RepeatDirection="Horizontal" DataKeyField="Key"&gt;
      &lt;ItemTemplate&gt;
              //HTML Formatting
              &lt;%# DataBinder.Eval(Container.DataItem, "CompanyName") %&gt;
          &lt;/ItemTemplate&gt;
      &lt;/asp:DataList&gt;
  </code></pre>
  
  <p>For whatever reason, "CompanyName" cannot be found. When outputting Container.DataItem.ToString(), all that appears is AdvertisementID (the first thing in the dictionary). What am I doing incorrectly?</p>
  
  <p><strong>EDIT:</strong> I want to also mention that I've attempted implementing this solution to no avail:
      <a href="https://stackoverflow.com/questions/645074/binding-datalist-to-dictionary">Binding DataList to Dictionary</a></p>
  
  <p><strong>EDIT 2:</strong> What I am trying to accomplish is the following:</p>
  
  <p>I have a bunch of information that I pulled from a database in a Dictionary. This dictionary is set up like Dictionary, both as strings. And I am trying to output this info to a webpage. </p>
  
  <p><strong>EDIT 3</strong>
  Using the solution below (Binding a list of objects instead of a dictionary), my asp code still cannot find the property "CompanyName". The object and all of the Strings within it appear in the DataItem in the debugger.</p>