Force event in dropdownlist

Last post 05-02-2007 1:48 PM by tiagosalgado. 2 replies.

Sort Posts:

  • Force event in dropdownlist

    05-02-2007, 12:40 PM
    • Loading...
    • tiagosalgado
    • Joined on 10-19-2004, 10:32 AM
    • Portugal
    • Posts 14

    I everyone,

    I need to force a event fire when i set a new selectedvalue. So, i've got this code:

    Protected

    Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

    DropDownList2.SelectedValue =

    CInt(dr("cod_loja").ToString.Trim)

    End

    Sub

     

    Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged

    Response.Write(

    "DONE")

    End

    Sub

    This is a sample code. The idea is to fire the SelectedIndexChanged event when SelectedValue is updated.

    Filed under: ,
  • Re: Force event in dropdownlist

    05-02-2007, 1:22 PM
    • Loading...
    • Benners_J
    • Joined on 04-09-2007, 9:56 PM
    • Posts 341

    I'm not sure if you can force the event to fire, but you can call the method directly.

    DropDownList2_SelectedIndexChanged(Nothing, Nothing)

    You can also add a check to make sure the value actually did change before you call the method.

  • Re: Force event in dropdownlist

    05-02-2007, 1:48 PM
    Answer
    • Loading...
    • tiagosalgado
    • Joined on 10-19-2004, 10:32 AM
    • Portugal
    • Posts 14

    I've found a way with "Call DropDownList_SelectedIndexChanged(DropDownList2,e)"

    Yes, before make the call, i check if the selectedvalue is different... if not, it don't call anything.

    Thanks.

Page 1 of 1 (3 items)
Microsoft Communities
Page view counter