S
Steve Schroeder
For some reason I cannot get the OnSelectedIndexChanged event to fire for a
listbox I have on a page. I'm able to populate the listbox with data from a
stored procedure, but cannot trigger the event. I do have EnableViewState =
True for the listbox. I'm imagining (wanting) to populate the listbox named:
lstNames by using the DataValueField from lstDepartments.
It's quite apparent though that the event is not triggering as I can misname
the stored procedure and no error occurs.
Here is the code, I'm sure it will wrap terribly however::
MGSurvey.aspx:
<FORM id="MGSurvey" runat="server">
<p style="Z-INDEX: 101; LEFT: 15px; POSITION: relative">
<asp:listbox id="lstDepartments" style="Z-INDEX: 102; POSITION: relative;
TOP: 6px" runat="server" EnableViewState="true" OnSelectedIndexChanged =
"lstDepartments_SelectedIndexChanged" Width="258px"
Height="118px"></asp:listbox>
<asp
anel id="pnDepartmentMembers" style="Z-INDEX: 103; POSITION: relative"
runat="server" Width="559px" Height="144px" BackColor="Transparent"
BorderColor="Transparent">
<asp:listbox id="lstNames" style="Z-INDEX: 103; LEFT: 15px; POSITION:
relative; TOP: 20px" runat="server" Width="258px" EnableViewState="True"
BackColor="Transparent"></asp:listbox>
</asp
anel>
</p>
</FORM>
MGSurvey.aspx.vb:
Public Sub lstDepartments_SelectedIndexChanged(ByVal sender As Object, ByVal
e As EventArgs)
If (Not IsPostBack) Then
adoConn.Open()
Dim adoCommDeptMembers As New SqlCommand("dbo.MG_EmployeesByDepartment "
& lstDepartments.SelectedItem.Value, adoConn)
With lstNames
.DataSource =
adoCommDeptMembers.ExecuteReader(CommandBehavior.CloseConnection)
.DataTextField = "Name"
.DataValueField = "tp_ID"
.DataBind()
End With
adoConn.Close()
End If
End Sub
listbox I have on a page. I'm able to populate the listbox with data from a
stored procedure, but cannot trigger the event. I do have EnableViewState =
True for the listbox. I'm imagining (wanting) to populate the listbox named:
lstNames by using the DataValueField from lstDepartments.
It's quite apparent though that the event is not triggering as I can misname
the stored procedure and no error occurs.
Here is the code, I'm sure it will wrap terribly however::
MGSurvey.aspx:
<FORM id="MGSurvey" runat="server">
<p style="Z-INDEX: 101; LEFT: 15px; POSITION: relative">
<asp:listbox id="lstDepartments" style="Z-INDEX: 102; POSITION: relative;
TOP: 6px" runat="server" EnableViewState="true" OnSelectedIndexChanged =
"lstDepartments_SelectedIndexChanged" Width="258px"
Height="118px"></asp:listbox>
<asp
runat="server" Width="559px" Height="144px" BackColor="Transparent"
BorderColor="Transparent">
<asp:listbox id="lstNames" style="Z-INDEX: 103; LEFT: 15px; POSITION:
relative; TOP: 20px" runat="server" Width="258px" EnableViewState="True"
BackColor="Transparent"></asp:listbox>
</asp
</p>
</FORM>
MGSurvey.aspx.vb:
Public Sub lstDepartments_SelectedIndexChanged(ByVal sender As Object, ByVal
e As EventArgs)
If (Not IsPostBack) Then
adoConn.Open()
Dim adoCommDeptMembers As New SqlCommand("dbo.MG_EmployeesByDepartment "
& lstDepartments.SelectedItem.Value, adoConn)
With lstNames
.DataSource =
adoCommDeptMembers.ExecuteReader(CommandBehavior.CloseConnection)
.DataTextField = "Name"
.DataValueField = "tp_ID"
.DataBind()
End With
adoConn.Close()
End If
End Sub