ASP.NET - sub1(DropDownList1) call for: Public Shared Sub sub1(ByVal ddlControl As DropDownList)

Asked By Timothy Vandeweerd on 13-Nov-14 02:16 PM
re: Sorting a DropDownList using ArrayList

This is an excellent article. Thank you!

I am trying to figure out how to call the following sub in ASP.Net (VB) in Visual Studio 2010

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


'Value of type 'System.Web.UI.WebControls.DropDownList' cannot be converted to 'WebApplication1.DropDownList'

End Sub

Public Shared Sub sub1(ByVal ddlControl As DropDownList)

Dim objListItem As ListItem = New ListItem("a".ToString(), "b".ToString())


'Argument not specified for parameter 'value' of 'Public Sub Add(key As Object, value As Object)'.

End Sub

Can someone please help?
Robbe Morris replied to Timothy Vandeweerd on 13-Nov-14 03:00 PM
Looks like  you may have a custom class named DropDownList.  Perhaps you have a namespace WebApplication1 and you have a class called DropDownList?  For whatever reason, the compiler isn't sure which "DropDownList" class you are attempting to use.  The one if your WebApplication1 namespace or the one in System.Web.UI.WebControls.

If you fully qualify the class you are working with, you should be ok.

Public Shared Sub sub1(ByVal ddlControl As System.Web.UI.WebControls.DropDownList)

Timothy Vandeweerd replied to Robbe Morris on 14-Nov-14 09:42 AM
Robbe Morris,


I greatly appreciate your assistance on this. Your suggestion worked prerfectly.

Have a super weekend and God Bless. Rocks!