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
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