I am trying to integrate an adapter to get support for the OptGroup tag in .net. i took the same adapter as i usually did (been a while, but no build errors or warnings). I set attributes when i add items into the DropDownList, and attempt to read them in the adapter and they seem to be set to Nothing. I entered breakpoints at points of interest and after being set, i can see the Attributes having a value. And in the adapter, the item remains but without said attribute.
To get every possible glitch out of the way i went into full hardcode for adding items, and here we have the result. The display does not group up, as the !=nothing never is met on the adapter.
declaration of list:
Dim item1 As New ListItem("potatoes", "1")
item1.Attributes("OptionGroup") = "optionGroup1"
Dim item2 As New ListItem("Onions", "2")
item2.Attributes("OptionGroup") = "optionGroup2" 'here the optiongroup is set, and debugger sees value to it.
Me.cboMaterial.Items.Add(item1)
Me.cboMaterial.Items.Add(item2)
where it fails in the adapter:
Dim list As DropDownList = Me.Control
Dim currentOptionGroup As String = ""
Dim renderedOptionGroups As New Collection
For Each item As ListItem In list.Items
If item.Attributes("OptionGroup") = "" Then 'here, the item is worth something (potatoes) but the OptionGroup is nothing.
RenderListItem(item, writer)
Else
If currentOptionGroup <> item.Attributes("OptionGroup") Then
If currentOptionGroup <> "" Then
RenderOptionGroupEndTag(writer)
End If
currentOptionGroup = item.Attributes("OptionGroup")
RenderOptionGroupBeginTag(currentOptionGroup, writer)
End If
RenderListItem(item, writer)
End If
Next
i must be missing something, perhaps trivial, but I've been looking at the same thing for too long. any help would be welcome.
edit: i have tried adding the attribute with secondary syntax... by desperation i guess.
item2.Attributes.Add("OptionGroup","optionGroup2")
it changes nothing :P