Hello,
I want to bind a RadListBox to a list of a simple class:
I would like to add separators to the list by category. Physically, that's easy - I just made the separator items disabled and applied a special css class. But, I am having trouble positioning them. Here's been my current approach:
This adds the items just fine but, of course, they are added below the first item in the new category. I tried reordering them in the DataBound event for the list but I haven't been able to get that to work.
Can anybody help - how can I add separator items?
Thanks,
Mike
I want to bind a RadListBox to a list of a simple class:
Public
Class
ExampleInfo
Property
ID as integer
Property
Text as
String
Property
Category as string
End
Class
I would like to add separators to the list by category. Physically, that's easy - I just made the separator items disabled and applied a special css class. But, I am having trouble positioning them. Here's been my current approach:
Private
_curCategory as string =
""
Private
Sub
mainList_ItemDataBound(sender
As
Object
, e
As
Telerik.Web.UI.RadListBoxItemEventArgs)
Dim
dataRow
As
ExampleInfo =
DirectCast
(e.Item.DataItem, ExampleInfo)
Dim
LocalCategory as string = dataRow.Category
If
_curCateogry <> LocalCategory
Then
Dim
sepItem
As
New
RadListBoxItem(LocalCategory, 0)
sepItem.Enabled =
False
sepItem.CssClass =
"listSeparator"
sepItem.Attributes.Add(
"isSeparator"
,
"True"
)
mainList.Items.Add(sepItem)
End
If
e.Item.Attributes.Add(
"isSeparator"
,
"False"
)
e.Item.ToolTip = dataRow.Description
End
Sub
This adds the items just fine but, of course, they are added below the first item in the new category. I tried reordering them in the DataBound event for the list but I haven't been able to get that to work.
Can anybody help - how can I add separator items?
Thanks,
Mike