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.
Shown below is the gridview and the method that loads the dropdownlist (supposedly):
<asp:GridView AutoGenerateColumns="false" runat="server" ID="SurveyView">
<Columns>
<asp:BoundField HeaderText="Questionnaire" DataField="Questionaire" ReadOnly="true"/>
<asp:BoundField HeaderText="QuestionID" DataField="Id" ReadOnly="true" Visible="false" />
<asp:BoundField HeaderText="IsBoolean" DataField="Filter" ReadOnly="true" Visible="false" />
<asp:TemplateField HeaderText="Response">
<ItemTemplate>
<asp:DropDownList ID="UserDropDown" runat="server" AppendDataBoundItems="true" DataSource="LoadDropdownList(Filter)" DataTextField="key" DataValueField="value"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
public Dictionary<String, String> GenerateDropdownList(bool BooleanFilterStatus)
{
Dictionary<String, String> tempStores = new Dictionary<string, string>() ;
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;
}
I was hoping that by using LoadDropdownList(), it would be populating the list. But that does not appear to work.
Any ideas or other possible solution would be appreciated.
How about something like
and in code-behind