Get the wrong sender in delegate

Discussion in 'ASP .Net Web Controls' started by John Kattestaart, Apr 6, 2006.

  1. 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
    John Kattestaart, Apr 6, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Showjumper
    Replies:
    2
    Views:
    1,804
    Showjumper
    Aug 2, 2003
  2. Dylan Parry
    Replies:
    2
    Views:
    550
  3. Replies:
    0
    Views:
    395
  4. Replies:
    0
    Views:
    356
  5. jodleren
    Replies:
    2
    Views:
    108
    Thomas 'PointedEars' Lahn
    Jan 31, 2008
Loading...

Share This Page