Get the wrong sender in delegate

  • Thread starter John Kattestaart
  • Start date
J

John Kattestaart

I'm trying to put two dynamic dropdownlists on form.
When i test the code, i get the wrong sender in my delegate.
Cannot figure out what i'm doing wrong...


Dim WithEvents ControlDropDownList As System.Web.UI.WebControls.DropDownList

Public Sub InitializeObject(ByVal parent As System.Web.UI.Control)

ControlDropDownList = New System.Web.UI.WebControls.DropDownList
ControlDropDownList.ID = "DropDown1"
parent.Controls.Add(ControlDropDownList)
ControlDropDownList.AutoPostBack = True
ControlDropDownList.EnableViewState = True
AddHandler ControlDropDownList.TextChanged, AddressOf
ControlDropDownList_TextChanged


ControlDropDownList.Width = New System.Web.UI.WebControls.Unit("200px")
ControlDropDownList.DataSource = Languages
ControlDropDownList.DataTextField = LanguageFields.Description.Name
'AccommodationFields.Description.Name
ControlDropDownList.DataValueField = LanguageFields.LanguageId.Name
'AccommodationFields.AccommodationId.Name
ControlDropDownList.DataBind()

ControlDropDownList = New System.Web.UI.WebControls.DropDownList
ControlDropDownList.ID = "DropDown2"
parent.Controls.Add(ControlDropDownList)
ControlDropDownList.AutoPostBack = True
ControlDropDownList.EnableViewState = True
AddHandler ControlDropDownList.TextChanged, AddressOf
ControlDropDownList_TextChanged


ControlDropDownList.Width = New System.Web.UI.WebControls.Unit("200px")
ControlDropDownList.DataSource = Locations
ControlDropDownList.DataTextField = LocationFields.Name.Name
'AccommodationFields.Description.Name
ControlDropDownList.DataValueField = LocationFields.LocationId.Name
'AccommodationFields.AccommodationId.Name
ControlDropDownList.DataBind()

End Sub


Protected Sub ControlDropDownList_TextChanged(ByVal sender As Object,
ByVal e As System.EventArgs)
Dim myText As String
myText = CType(sender, System.Web.UI.Control).ID
End Sub

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top