I'd like to iterate over the value of each entry in a c# dictionary within my asp.net repeater.
My IDictionary
is nothing special - Just key-value pairs of data, and the values are arrays of strings. I'm trying to create a form select element with materializecss (Docs, see "Optgroups"). Currently, what I have is this:
...
<div class="input-field">
<asp:Repeater runat="server" ID="optgroupSelect">
<HeaderTemplate>
<select>
</HeaderTemplate>
<ItemTemplate>
<optgroup label="<%# Eval("Key") %>">
<%-- Here comes the problem --%>
<%# foreach (string s in Eval("Value")) { %>
<option value="<%=s.toLower()%>"><%=s%></option>
<%# } %>
</optgroup>
</ItemTemplate>
<FooterTemplate>
</select>
<label>Please select something</label>
</FooterTemplate>
</asp:Repeater>
</div>
...
I've worked with PHP for the last couple years and feel that I'm missing the mindset of an asp.net dev - Still, I have to do this for work. Obviously, the above code does not work, but it highlights what I'd like to achieve. I've gone through the whole System.Web.UI.WebControls list to maybe find a component which could iterate over the databound value array, but most of them have their own style which I don't want (since everything should match with materializecss).
I appreciate any help towards solving this, thanks for taking your time!
Note: My pages are .aspx
Web Forms in the Asp.net Framework 4.8