zeratulvlad
New Member
I've added the code:<BR><BR><asp:dropdownlist id="lstlevel" Runat="server" OnSelectedIndexChanged="Load_Units()"><BR><BR>to my web form, but when I create the Load_Units() sub I have to put the byVal and e arguments in the function definition. Do I need to add anything to the function call (above) to pass those arguments to the function? The error I'm currently getting is:<BR><BR>Compilation Error <BR>Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. <BR><BR>Compiler Error Message: BC30455: Argument not specified for parameter 'e' of 'Public Sub Load_Units(sender As Object, e As System.EventArgs)'.<BR><BR>Here's the function code:<BR><BR> Public Sub Load_Units(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstlevel.SelectedIndexChanged<BR> Dim conn As SqlConnection = New SqlConnection(Application("ConnString"))<BR> conn.Open()<BR> 'Get Fieldnames from CompanyHierarchy Table<BR> Dim sql As String<BR> sql = "SELECT FieldName, UnitName FROM CompanyHierarchy WHERE ProjectID=" & Session("projectid")<BR> sql = sql & " AND HierarchyID=" & lstlevel.SelectedItem.Value<BR> Dim cmd As SqlCommand = New SqlCommand(sql, conn)<BR> Dim sdr As SqlDataReader = cmd.ExecuteReader<BR> Dim FieldName As String = sdr("FieldName")<BR> Dim UnitName As String = sdr("UnitName")<BR><BR> sql = "SELECT FieldName, UnitName FROM CompanyHierarchy WHERE ProjectID=" & Session("projectid")<BR> sql = sql & " AND HierarchyID=" & Session("levelid")<BR> Dim cmd2 As SqlCommand = New SqlCommand(sql, conn)<BR> Dim sdr2 As SqlDataReader = cmd.ExecuteReader<BR><BR> 'Get list of units from Hierarchy##### view to fill Units box<BR> sql = "SELECT " & sdr("FieldName") & ", " & sdr("UnitName") & " FROM Hierarchy" & Session("projectID")<BR> sql = sql & " WHERE " & sdr2("FieldName") & "='" & Session("unitid") & "'"<BR> cmd.CommandText = sql<BR> sdr2 = cmd.ExecuteReader<BR><BR> Do While sdr2.Read()<BR> Dim liItem As ListItem = New ListItem(sdr2(FieldName) & " - " & sdr(UnitName), sdr(FieldName))<BR> lstUnits.Items.Add(liItem)<BR> Loop<BR> conn.Close()<BR><BR> End Sub<BR>