[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Drop down list onselectedindexchanged won't call function

(aandrews)

12/25/2002 10:28:00 PM

I have a drop down list that when it's index changes, will populate
another drop down list, etc. There are actually 3 DDLs, 2 textboxes,
and a datalist. The weird thing about this is it worked for awhile
perfectly. Once one drop down list index changed, it populated the
next, etc. Then, out of nowhere, without me making ANY changes, it
stops working. It actually worked on the server but not remotely. THen
it wouldn't even work on the server. It will do the autopostback when
I do select something from the first DDL but after it posts back, the
first DDL's selected index goes back to 0. When I debug, it never
calls the function in the DDL's onselectedindexchanged event. PLEASE
HELP! Here is some code:

<%@ Page Language="vb" AutoEventWireup="false"
enableViewStateMac="false" Codebehind="HotelComplaintForm.aspx.vb"
Inherits="HotelComplaints.HotelComplaintForm"%>
...
<form id="HotelComplaintForm" onsubmit="return validateForm(this)"
method="post" runat="server">
...
HERE'S THE FIRST DROP DOWN:

<asp:dropdownlist id="drpBrand" runat="server" Width="200px"
onselectedindexchanged="showStateCountry"
autopostback="True"></asp:dropdownlist>

SECOND DDL:
<asp:dropdownlist id="drpStateCountry" Width="200"
onselectedindexchanged="fillInnCode" autopostback="True"
Runat="server"></asp:dropdownlist>

HERE's THE CODE FOR showStateCountry (the function that doesn't get
called when the index changes for drpBrand):

Sub showStateCountry(ByVal sender As Object, ByVal e As EventArgs)


Dim ldtsData2 As New DataSet()
Dim lstrBrandCd As String = Me.drpBrand.SelectedItem.Value

Dim lstrSqlStmt2 As String = "String representing Select Statement"
Dim ldtaAdapter2 As New SqlDataAdapter(lstrSqlStmt2,
"CONNECTIONSTRING")

ldtaAdapter2.Fill(ldtsData2, "state")

Me.drpStateCountry.DataValueField = "state"
Me.drpStateCountry.DataTextField = "stateCountry"
Me.drpStateCountry.DataSource = ldtsData2
Me.drpStateCountry.DataBind()
Me.drpStateCountry.Items.Insert(0, "...")
Me.drpStateCountry.SelectedIndex = 0
Me.lblStateCountry.Visible = True
Me.drpStateCountry.Visible = True
ldtsData2 = Nothing
ldtaAdapter2 = Nothing

End Sub

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load


If Not Page.IsPostBack Then
Dim ldtsData As New DataSet()
Dim lstrSqlStmt As String = "String representing Select Statement"
Dim ldtaAdapter As New SqlDataAdapter(lstrSqlStmt, "CONNECTION
STRING')

ldtaAdapter.Fill(ldtsData, "brands")

Me.drpBrand.DataValueField = "brand_cd"
Me.drpBrand.DataTextField = "brand"
Me.drpBrand.DataSource = ldtsData
Me.drpBrand.DataBind()
ldtsData = Nothing
ldtaAdapter = Nothing
Me.drpBrand.Items.Insert(0, "...")
Me.drpBrand.SelectedIndex = 0
End If

End sub

REMEMBER, it worked at first, and then out of nowhere, it stopped
working-please help me. The problem is somewhere between the
autopostback and the onselectedindexchanged event because it never
gets to "showstatecountry".

Could it have something to do with AutoEventWireup? Or do I need to
add a handle to showstatecountry? (I've tried that and it didn't work
unless I just flat out did it wrong.) HELP!