Combo Box Add Value Too

nate

Freshman
Joined
Dec 2, 2006
Messages
36
I have this in a separate class file:

Code:
Imports Microsoft.VisualBasic

Public Class cboAddItem

    Public Value As String
    Public Item As String

    Public Sub New(ByVal NewItem As String, ByVal NewValue As String)
        Value = NewValue
        Item = NewItem
    End Sub

    Public Overrides Function ToString() As String
        Return Item
    End Function

End Class


I then use this in my page code:

Code:
cboBusinessCategory.Items.Add(New cboAddItem("Show All", "1"))


What am I missing or doing wrong? I get the intellisense error overload, add cannot be called with these arguments. cboAddItem can not be converted to string/listitem.

Thanks in advance.
 
As the intellisense is indicating, you can only add a string or a ListItem to the DropDownList.Items collection.

You should however be able to store the cboAddItem objects in a collection (such as a List(Of cboAddItem) and data bind to this collection.
 
Back
Top