antoinette
1/2/2003 6:47:00 PM
asp.net:
I still need help on this. I'll explain again. I have 3
drop down lists that populate each other once one's index
changes. For the first drop down, once the user selects
from it, it should post back and populate the next one and
keep its selection. Well this doesn't get done.
I really have no idea why the first one (drpBrand) won't
populate the 2nd drop down called (drpStateCountry). When
I select something in the first drop down, it will repost
the page (I think even though when I put an else statement
to write something for the If Not Page.IsPostBack, it
never got there), but it will set the index for the first
drop down back to 0. It appears that the post back isn't
really posting back. I've put breakpoints up around the
event for the selectedindexchanged but it never breaks
there. I did notice that when I viewed the html source
that it doesn't send a second argument to this
javascript:
function __doPostBack(eventTarget, eventArgument) {
var theform = document.HotelComplaintForm;
theform.__EVENTTARGET.value = eventTarget;
theform.__EVENTARGUMENT.value =
eventArgument;
theform.submit();
}
This is how the drop down looks when I view the html
source for the page before AND after the post back (first
line)- and I have no idea where the language="javascript"
came from:
<select name="drpBrand" id="drpBrand"
onchange="__doPostBack('drpBrand','')"
language="javascript" style="width:200px;">
There's nothing being sent in the second argument for
_doPostBack eventArgument-could this be the problem? What
does eventArgument get? The value selected?
Here's the code for the first drop down:
<asp:dropdownlist AutoPostBack=True EnableViewSTate=True
id="drpBrand" runat="server"
Width="200px"></asp:dropdownlist>
Here's the code for its event which should populate the
drpStateCountry:
Private Sub drpBrand_SelectedIndexChanged(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
drpBrand.SelectedIndexChanged
Dim ldtsData2 As New DataSet()
Dim lstrBrandCd As String =
Me.drpBrand.SelectedItem.Value
Dim lstrSqlStmt2 As String = "Select Statement"
Dim ldtaAdapter2 As New SqlDataAdapter
(lstrSqlStmt2, "connection string")
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
Page_load (which loads the first drop down and works fine):
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 = "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
PLEASE SOMEBODY HELP!!!!