Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > problems after a first postback

Reply
Thread Tools

problems after a first postback

 
 
Ben
Guest
Posts: n/a
 
      07-03-2003
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
 
Reply With Quote
 
 
 
 
Duray AKAR
Guest
Posts: n/a
 
      07-03-2003
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
>.
>

 
Reply With Quote
 
 
 
 
Ben
Guest
Posts: n/a
 
      07-03-2003
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
>>.
>>

>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I raise a postback ? Session variable only visible after postback. Please help gce ASP .Net 2 05-08-2005 05:55 AM
Postback not being set to True on first postback =?Utf-8?B?Q2hhZA==?= ASP .Net 2 04-04-2005 06:17 PM
Warning re postback problems after Windows Server service pack installation Doug ASP .Net 0 10-26-2004 03:10 PM
After adding Textboxes to calender control, how to get values after Postback? Andreas Klemt ASP .Net 0 02-01-2004 02:54 AM
Datalist selects Item after first click, but does apply the SelectedItemTemplate after the second click only Dirk Meusel ASP .Net 1 08-19-2003 09:56 AM



Advertisments