problems after a first postback

Discussion in 'ASP .Net Web Controls' started by Ben, Jul 3, 2003.

  1. Ben

    Ben Guest

    Hello

    I create two dropdownlists, set their autopostback
    property to true and instanciate a SelectedIndexChanged
    for each of them (just binding some drop down lists ).

    When I run the solution, everything works fine the first
    time I change one of the drop down list. Once the first
    postback done, no more event fires when I change a
    dropdownlist. It seems that the event associated with
    the ddl are no longer available.

    Please help me with this...

    Thanks a lot

    Ben
     
    Ben, Jul 3, 2003
    #1
    1. Advertising

  2. Ben

    Duray AKAR Guest

    Ben,

    Does the selectedIndexChanged event fire after submitting
    the form by other means (like a submit button), or it does
    not fire at all?

    You might be doing something in the postback event that
    will result indirectly in modifying the autopostback
    property, or even deattach the event handlers...

    or adding the event handlers in codebehind in page_load
    instead of having them them on the aspx page and having
    them in the WebForm generated code section might result in
    this situation too(in c#)..

    can you post the code ?

    Duray


    >-----Original Message-----
    >Hello
    >
    >I create two dropdownlists, set their autopostback
    >property to true and instanciate a SelectedIndexChanged
    >for each of them (just binding some drop down lists ).
    >
    >When I run the solution, everything works fine the first
    >time I change one of the drop down list. Once the first
    >postback done, no more event fires when I change a
    >dropdownlist. It seems that the event associated with
    >the ddl are no longer available.
    >
    >Please help me with this...
    >
    >Thanks a lot
    >
    >Ben
    >.
    >
     
    Duray AKAR, Jul 3, 2003
    #2
    1. Advertising

  3. Ben

    Ben Guest

    Thank you for such a fast reply

    The selectedIndexChanged fire the first time ,
    initializing another list, but nothing is happening if I
    change the selection again after.

    Here is the code...I'm still a beginner on .net (also in
    english ;( )

    Code:
    Private Sub Page_Load(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles MyBase.Load
    
    'If it's the real page load
    If Not Page.IsPostBack Then
    
    InitializeDDL()
    DDLGroupe.Enabled = False
    
    End If
    
    End Sub
    
    Private Sub InitializeDDL()
    
    ' Initialize the general drop down lists
    InitializeDDLDepartement()
    InitializeDDLVille()
    InitializeDDLSite()
    InitializeDDLHoraire()
    InitializeDDLChambre()
    InitializeDDLChambreBloque()
    
    
    End Sub
    
    ' ** All the other initialize are the same **
    Private Sub InitializeDDLDepartement()
    
    ' open the connection
    cn.Open()
    Dim sql As String = "SELECT DISTINCT
    DepartementID, Nom FROM Departement"
    
    Dim cmd As New SqlCommand(sql, cn)
    
    'Bind the DDL
    DDLDept.DataSource = cmd.ExecuteReader()
    DDLDept.DataTextField = "Nom"
    DDLDept.DataValueField = "DepartementId"
    DDLDept.DataBind()
    'Close the connection
    cn.Close()
    End Sub
    
    ' Here's the selectedIndexChanged
    Private Sub DDLDept_selectedIndexChanged(ByVal sender
    As System.Object, ByVal e As System.EventArgs) Handles
    DDLDept.SelectedIndexChanged
    
    ' enabled the ddl
    DDLGroupe.Enabled = True
    
    ' establish the connexion
    cn.Open()
    
    ' SQL request used to bind the DDL
    Dim sql As String = " Select anything FROM
    anything WHERE (Departement.DepartementId = " &
    DDLDept.SelectedItem.Value & ")"
    
    Dim cmd As New SqlCommand(sql, cn)
    
    'Bind the DDL
    DDLGroupe.DataSource = cmd.ExecuteReader()
    DDLGroupe.DataTextField = "Nom"
    DDLGroupe.DataValueField = "GroupeId"
    DDLGroupe.DataBind()
    'Fermer les connexions
    cn.Close()
    
    End Sub
    
    
    Is there any way to associate the selectedIndexChanged of
    a DDL with an event directly in the page load?

    >-----Original Message-----
    >Ben,
    >
    >Does the selectedIndexChanged event fire after

    submitting
    >the form by other means (like a submit button), or it

    does
    >not fire at all?
    >
    >You might be doing something in the postback event that
    >will result indirectly in modifying the autopostback
    >property, or even deattach the event handlers...
    >
    >or adding the event handlers in codebehind in page_load
    >instead of having them them on the aspx page and having
    >them in the WebForm generated code section might result

    in
    >this situation too(in c#)..
    >
    >can you post the code ?
    >
    >Duray
    >
    >
    >>-----Original Message-----
    >>Hello
    >>
    >>I create two dropdownlists, set their autopostback
    >>property to true and instanciate a SelectedIndexChanged
    >>for each of them (just binding some drop down lists ).
    >>
    >>When I run the solution, everything works fine the

    first
    >>time I change one of the drop down list. Once the

    first
    >>postback done, no more event fires when I change a
    >>dropdownlist. It seems that the event associated with
    >>the ddl are no longer available.
    >>
    >>Please help me with this...
    >>
    >>Thanks a lot
    >>
    >>Ben
    >>.
    >>

    >.
    >
     
    Ben, Jul 3, 2003
    #3
    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. Dirk Meusel
    Replies:
    1
    Views:
    3,075
    Dirk Meusel
    Aug 19, 2003
  2. Andreas Klemt
    Replies:
    0
    Views:
    846
    Andreas Klemt
    Feb 1, 2004
  3. Doug
    Replies:
    0
    Views:
    318
  4. =?Utf-8?B?Q2hhZA==?=

    Postback not being set to True on first postback

    =?Utf-8?B?Q2hhZA==?=, Apr 4, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    534
    =?Utf-8?B?Q2hhZA==?=
    Apr 4, 2005
  5. gce
    Replies:
    2
    Views:
    1,743
Loading...

Share This Page