I am working with the ItemTemplate of the combo box and wanted to know how to add an item to the collection that didn't match the specified item template. Here's my example:
My declaration on the ASP.NET page:
The object is a POCO object stored in a generic list:
And my databinding:
However, when I select an item in the list I see the namespace of the object declaration and the item I add doesn't match the template, so it displayes as an empty table. I would prefer to use the templates idea, but is this scenario possible?
My declaration on the ASP.NET page:
| <telerik:RadComboBox ID="drpObjects" runat="server" AutoPostBack="true" Skin="Vista" AllowCustomText="false" |
| DropDownWidth="350px" Height="250px"> |
| <CollapseAnimation Type="InQuint" Duration="200" /> |
| <ExpandAnimation Type="OutQuint" Duration="200" /> |
| <ItemTemplate> |
| <table style="border-bottom: 1px dotted #dfdfdf; margin-bottom: 10px; font-size: 11px;" |
| width="98%"> |
| <tr> |
| <td> |
| <%#DataBinder.Eval(Container.DataItem, "LineItemID")%> |
| </td> |
| <td> |
| <%#DataBinder.Eval(Container.DataItem, "Description")%> |
| </td> |
| </tr> |
| </table> |
| </ItemTemplate> |
| </telerik:RadComboBox> |
The object is a POCO object stored in a generic list:
| Namespace Entities |
| Public Class CostCenterObject |
| Inherits BaseDataEntity |
| Private _LineItemID As Integer = 0 |
| Private _Description As String = "" |
| Private _CategoryID As Integer = 0 |
| Private _ReviewOnly As Boolean |
| Private _CreateDate As DateTime |
| Private _CreateBy As String = "" |
| Private _ModifyDate As DateTime |
| Private _ModifyBy As String = "" |
| Private _Active As Boolean |
| Private _Category As String = "" |
| Private _CategoryGroupName As String = "" |
| Public ReadOnly Property LineItemID() As Integer |
| Get |
| Return _LineItemID |
| End Get |
| End Property |
| Public ReadOnly Property Description() As String |
| Get |
| Return _Description |
| End Get |
| End Property |
| Public ReadOnly Property CategoryID() As Integer |
| Get |
| Return _CategoryID |
| End Get |
| End Property |
| Public ReadOnly Property ReviewOnly() As Boolean |
| Get |
| Return _ReviewOnly |
| End Get |
| End Property |
| Public ReadOnly Property CreateDate() As DateTime |
| Get |
| Return _CreateDate |
| End Get |
| End Property |
| Public ReadOnly Property CreateBy() As String |
| Get |
| Return _CreateBy |
| End Get |
| End Property |
| Public ReadOnly Property ModifyDate() As DateTime |
| Get |
| Return _ModifyDate |
| End Get |
| End Property |
| Public ReadOnly Property ModifyBy() As String |
| Get |
| Return _ModifyBy |
| End Get |
| End Property |
| Public ReadOnly Property Active() As Boolean |
| Get |
| Return _Active |
| End Get |
| End Property |
| Public ReadOnly Property Category() As String |
| Get |
| Return _Category |
| End Get |
| End Property |
| Public ReadOnly Property CategoryGroupName() As String |
| Get |
| Return _CategoryGroupName |
| End Get |
| End Property |
| End Class |
| ' Instantiation code omitted... |
| End Namespace |
And my databinding:
| Dim Objects As List(Of CostCenterObject) |
| Objects = _AppController.GetAvailableObjects(drpYear.SelectedValue) |
| drpObjects.DataSource = Objects |
| drpObjects.DataBind() |
| drpObjects.Items.Insert(0, New RadComboBoxItem("- ALL -", "- ALL -")) |
However, when I select an item in the list I see the namespace of the object declaration and the item I add doesn't match the template, so it displayes as an empty table. I would prefer to use the templates idea, but is this scenario possible?