title: How do I dynamically load a dropdownlist in a Webform Gridview?
body: <p>I have a templated Gridview where I only want to display one column (Questions --- these are database obtained), and the other the dropdownlist of possible answers (Options). The dropdownlist's values change depending on the type of the question. There are only 2 types: T/F or ranged (Lo, Med, High). So if the question is type 1, the dropdownlist should just display T/F. Likewise if it's type II. </p>
  
  <p>Shown below is the gridview and the method that loads the dropdownlist (supposedly):</p>
  
  <pre><code>    &lt;asp:GridView AutoGenerateColumns="false" runat="server" ID="SurveyView"&gt;
      &lt;Columns&gt;
  
          &lt;asp:BoundField HeaderText="Questionnaire" DataField="Questionaire" ReadOnly="true"/&gt;
          &lt;asp:BoundField HeaderText="QuestionID" DataField="Id" ReadOnly="true" Visible="false" /&gt;
          &lt;asp:BoundField HeaderText="IsBoolean" DataField="Filter" ReadOnly="true" Visible="false" /&gt;
          &lt;asp:TemplateField HeaderText="Response"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:DropDownList ID="UserDropDown" runat="server" AppendDataBoundItems="true" DataSource="LoadDropdownList(Filter)" DataTextField="key" DataValueField="value"&gt;&lt;/asp:DropDownList&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  
  
          public Dictionary&lt;String, String&gt; GenerateDropdownList(bool BooleanFilterStatus)
      {
          Dictionary&lt;String, String&gt; tempStores = new Dictionary&lt;string, string&gt;() ; 
          if (BooleanFilterStatus)
          {
              tempStores.Add(Boolean.TrueString, Boolean.TrueString);
              tempStores.Add(Boolean.FalseString, Boolean.FalseString);
          }
          else
          {
              tempStores.Add("NONE", "NIL");
              tempStores.Add("Lo", "Low");
              tempStores.Add("Medium", "Medium");
              tempStores.Add("High", "High"); 
          }
  
          return tempStores; 
      }
  </code></pre>
  
  <p>I was hoping that by using LoadDropdownList(), it would be populating the list. But that does not appear to work. </p>
  
  <p>Any ideas or other possible solution would be appreciated.</p>