Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have this in a separate class file:

 

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:

 

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.

Ignorance begins with I.
  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...