Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populate a DropDownList based on a selection in another DropDownList

Status
Not open for further replies.

mThomas

Instructor
May 3, 2001
404
US
I have two drop down lists. I want to dynamically change the option values in one list based on a selection in the other list.

Can someone get me started on how to do this?

tia... mike
 
I had planned to pull the data from tables, though at this point the list boxes are hard coded. I can live with them being hard coded.

Here is part of the form code I'm using with the tables. I want to make a selection in the jobboard list and auto populate the categories list box.

I do have MS SQL tables with the data for each of the list boxes, so if it is easier to grab the data fram a table and do it or easier to hard code the options I would prefer, at this point, to do whichever is easier.

Code:
<td><asp:DropDownList id="category" runat="server">
   <asp:ListItem value="21">customer s.</asp:ListItem>
   <asp:ListItem value="22">restaurant</asp:ListItem>
   <asp:ListItem value="23">marketing</asp:ListItem>
   <asp:ListItem value="24">management</asp:ListItem>
   <asp:ListItem value="25">arts</asp:ListItem>
   <asp:ListItem value="26">banking</asp:ListItem>
   <asp:ListItem value="27">retail</asp:ListItem>
   <asp:ListItem value="28">sales</asp:ListItem>
   <asp:ListItem value="29">adv</asp:ListItem>
   <asp:ListItem value="30">clerical</asp:ListItem>	
</asp:DropDownList></td>
<td><asp:DropDownList id="jobboard" runat="server">
   <asp:ListItem value="1">Monster</asp:ListItem>
   <asp:ListItem value="2">HotJobs</asp:ListItem>
</asp:DropDownList></td>

tia... mike

Just in case, here is all the code I'm using so far.

Code:
<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>

<script runat="server">

		'set up connection string
    Dim ConnectionString As String = "server=IP; user id=userID; password=Pass; database=Database"
		

		Sub doInsert(Sender As Object, E As EventArgs)
		
		

		 
		 		'do the applicants insert
        Dim myConnection As New SqlConnection(ConnectionString)
        Dim UpdateCommand As SqlCommand = new SqlCommand()
        UpdateCommand.Connection = myConnection
        
				UpdateCommand.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_1.text + "', '" + lname_1.text + "', '" + fname_1.text + "', '" + state.SelectedItem.Value + "')"				
        
        myConnection.Open()
        UpdateCommand.ExecuteNonQuery()
				
				
			  ' grab the PK	
        Dim APK As String = "SELECT applicant_id from Applicants where email = '" + email_1.text + "'"

        Dim da as New SqlDataAdapter(APK, ConnectionString)
        Dim ds as New DataSet("applicant_id")
		    da.Fill(ds, "applicant_id")
		    Dim pk as String = ds.Tables(0).Rows(0).Item("Applicant_id")
		
		    'Response.Write(pk)	
		
		    ' insert into catappjob
		
        Dim InsertCatAppJob As SqlCommand = new SqlCommand()
        InsertCatAppJob.Connection = myConnection
        
				InsertCatAppJob.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob.ExecuteNonQuery()	


if email_2.text <> "" then

				'begin insert 2	
						
				 Dim SelectCommand2 As String = "SELECT email, fname, lname, state from Applicants order by lname"		
         Dim myCommand As New SqlDataAdapter(SelectCommand2, myConnection)
    
         Dim dd As New DataSet()
         myCommand.Fill(dd)
    
         ' add a new blank row to the end of the data
         Dim rowValues As Object() = {""}
         dd.Tables(0).Rows.Add(rowValues)

        Dim UpdateCommand2 As SqlCommand = new SqlCommand()
        UpdateCommand2.Connection = myConnection
        
				UpdateCommand2.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_2.text + "', '" + lname_2.text + "', '" + fname_2.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand2.ExecuteNonQuery()													
						

			  ' grab the PK	2
        Dim APK2 As String = "SELECT applicant_id from Applicants where email = '" + email_2.text + "'"

        Dim da2 as New SqlDataAdapter(APK2, ConnectionString)
        Dim ds2 as New DataSet("applicant_id")
		    da2.Fill(ds2, "applicant_id")
		    Dim pk2 as String = ds2.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk2) 'print to screen the pk2

			  Dim InsertCatAppJob2 As SqlCommand = new SqlCommand()
        InsertCatAppJob2.Connection = myConnection
        
				InsertCatAppJob2.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk2 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob2.ExecuteNonQuery()	

end if

if email_3.text <> "" then

					'begin insert 3	
						
        Dim UpdateCommand3 As SqlCommand = new SqlCommand()
        UpdateCommand3.Connection = myConnection
        
				UpdateCommand3.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_3.text + "', '" + lname_3.text + "', '" + fname_3.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand3.ExecuteNonQuery()													
						

			  ' grab the PK	3
        Dim APK3 As String = "SELECT applicant_id from Applicants where email = '" + email_3.text + "'"

        Dim da3 as New SqlDataAdapter(APK3, ConnectionString)
        Dim ds3 as New DataSet("applicant_id")
		    da3.Fill(ds3, "applicant_id")
		    Dim pk3 as String = ds3.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk3) 'print to screen the pk3

			  Dim InsertCatAppJob3 As SqlCommand = new SqlCommand()
        InsertCatAppJob3.Connection = myConnection
        
				InsertCatAppJob3.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk3 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob3.ExecuteNonQuery()	

end if

if email_4.text <> "" then

					'begin insert 4	
						
        Dim UpdateCommand4 As SqlCommand = new SqlCommand()
        UpdateCommand4.Connection = myConnection
        
				UpdateCommand4.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_4.text + "', '" + lname_4.text + "', '" + fname_4.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand4.ExecuteNonQuery()													
						

			  ' grab the PK	4
        Dim APK4 As String = "SELECT applicant_id from Applicants where email = '" + email_4.text + "'"

        Dim da4 as New SqlDataAdapter(APK4, ConnectionString)
        Dim ds4 as New DataSet("applicant_id")
		    da4.Fill(ds4, "applicant_id")
		    Dim pk4 as String = ds4.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk4) 'print to screen the pk4

			  Dim InsertCatAppJob4 As SqlCommand = new SqlCommand()
        InsertCatAppJob4.Connection = myConnection
        
				InsertCatAppJob4.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk4 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob4.ExecuteNonQuery()	

end if

if email_5.text <> "" then
				
				
					'begin insert 5	

        Dim UpdateCommand5 As SqlCommand = new SqlCommand()
        UpdateCommand5.Connection = myConnection
        
				UpdateCommand5.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_5.text + "', '" + lname_5.text + "', '" + fname_5.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand5.ExecuteNonQuery()													
						

			  ' grab the PK	5
        Dim APK5 As String = "SELECT applicant_id from Applicants where email = '" + email_5.text + "'"

        Dim da5 as New SqlDataAdapter(APK5, ConnectionString)
        Dim ds5 as New DataSet("applicant_id")
		    da5.Fill(ds5, "applicant_id")
		    Dim pk5 as String = ds5.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk5) 'print to screen the pk5

			  Dim InsertCatAppJob5 As SqlCommand = new SqlCommand()
        InsertCatAppJob5.Connection = myConnection
        
				InsertCatAppJob5.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk5 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob5.ExecuteNonQuery()

end if

if email_6.text <> "" then				
				
        'begin insert 6

        Dim UpdateCommand6 As SqlCommand = new SqlCommand()
        UpdateCommand6.Connection = myConnection
        
				UpdateCommand6.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_6.text + "', '" + lname_6.text + "', '" + fname_6.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand6.ExecuteNonQuery()													
						

			  ' grab the PK	6
        Dim APK6 As String = "SELECT applicant_id from Applicants where email = '" + email_6.text + "'"

        Dim da6 as New SqlDataAdapter(APK6, ConnectionString)
        Dim ds6 as New DataSet("applicant_id")
		    da6.Fill(ds6, "applicant_id")
		    Dim pk6 as String = ds6.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk6) 'print to screen the pk6

			  Dim InsertCatAppJob6 As SqlCommand = new SqlCommand()
        InsertCatAppJob6.Connection = myConnection
        
				InsertCatAppJob6.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk6 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob6.ExecuteNonQuery()
				

end if

if email_7.text <> "" then
				
        'begin insert 7
				
				Dim UpdateCommand7 As SqlCommand = new SqlCommand()
        UpdateCommand7.Connection = myConnection
        
				UpdateCommand7.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_7.text + "', '" + lname_7.text + "', '" + fname_7.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand7.ExecuteNonQuery()													
						

			  ' grab the PK	7
        Dim APK7 As String = "SELECT applicant_id from Applicants where email = '" + email_7.text + "'"

        Dim da7 as New SqlDataAdapter(APK7, ConnectionString)
        Dim ds7 as New DataSet("applicant_id")
		    da7.Fill(ds7, "applicant_id")
		    Dim pk7 as String = ds7.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk7) 'print to screen the pk7

			  Dim InsertCatAppJob7 As SqlCommand = new SqlCommand()
        InsertCatAppJob7.Connection = myConnection
        
				InsertCatAppJob7.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk7 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob7.ExecuteNonQuery()

end if

if email_8.text <> "" then				
				
        'begin insert 8
				
				Dim UpdateCommand8 As SqlCommand = new SqlCommand()
        UpdateCommand8.Connection = myConnection
        
				UpdateCommand8.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_8.text + "', '" + lname_8.text + "', '" + fname_8.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand8.ExecuteNonQuery()													
						

			  ' grab the PK	8
        Dim APK8 As String = "SELECT applicant_id from Applicants where email = '" + email_8.text + "'"

        Dim da8 as New SqlDataAdapter(APK8, ConnectionString)
        Dim ds8 as New DataSet("applicant_id")
		    da8.Fill(ds8, "applicant_id")
		    Dim pk8 as String = ds8.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk8) 'print to screen the pk8

			  Dim InsertCatAppJob8 As SqlCommand = new SqlCommand()
        InsertCatAppJob8.Connection = myConnection
        
				InsertCatAppJob8.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk8 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob8.ExecuteNonQuery()

end if

if email_9.text <> "" then				
				
        'begin insert 9
				
				Dim UpdateCommand9 As SqlCommand = new SqlCommand()
        UpdateCommand9.Connection = myConnection
        
				UpdateCommand9.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_9.text + "', '" + lname_9.text + "', '" + fname_9.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand9.ExecuteNonQuery()													
						

			  ' grab the PK	9
        Dim APK9 As String = "SELECT applicant_id from Applicants where email = '" + email_9.text + "'"

        Dim da9 as New SqlDataAdapter(APK9, ConnectionString)
        Dim ds9 as New DataSet("applicant_id")
		    da9.Fill(ds9, "applicant_id")
		    Dim pk9 as String = ds9.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk9) 'print to screen the pk9

			  Dim InsertCatAppJob9 As SqlCommand = new SqlCommand()
        InsertCatAppJob9.Connection = myConnection
        
				InsertCatAppJob9.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk9 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob9.ExecuteNonQuery()
				

end if

if email_10.text <> "" then
				
        'begin insert 10
				
				Dim UpdateCommand10 As SqlCommand = new SqlCommand()
        UpdateCommand10.Connection = myConnection
        
				UpdateCommand10.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_10.text + "', '" + lname_10.text + "', '" + fname_10.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand10.ExecuteNonQuery()													
						

			  ' grab the PK	10
        Dim APK10 As String = "SELECT applicant_id from Applicants where email = '" + email_10.text + "'"

        Dim da10 as New SqlDataAdapter(APK10, ConnectionString)
        Dim ds10 as New DataSet("applicant_id")
		    da10.Fill(ds10, "applicant_id")
		    Dim pk10 as String = ds10.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk10) 'print to screen the pk10

			  Dim InsertCatAppJob10 As SqlCommand = new SqlCommand()
        InsertCatAppJob10.Connection = myConnection
        
				InsertCatAppJob10.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk10 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob10.ExecuteNonQuery()
				
end if

if email_11.text <> "" then
				
        'begin insert 11
				
				Dim UpdateCommand11 As SqlCommand = new SqlCommand()
        UpdateCommand11.Connection = myConnection
        
				UpdateCommand11.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_11.text + "', '" + lname_11.text + "', '" + fname_11.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand11.ExecuteNonQuery()													
						

			  ' grab the PK	11
        Dim APK11 As String = "SELECT applicant_id from Applicants where email = '" + email_11.text + "'"

        Dim da11 as New SqlDataAdapter(APK11, ConnectionString)
        Dim ds11 as New DataSet("applicant_id")
		    da11.Fill(ds11, "applicant_id")
		    Dim pk11 as String = ds11.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk11) 'print to screen the pk11

			  Dim InsertCatAppJob11 As SqlCommand = new SqlCommand()
        InsertCatAppJob11.Connection = myConnection
        
				InsertCatAppJob11.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk11 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob11.ExecuteNonQuery()
				
end if

if email_12.text <> "" then
				
        'begin insert 12
				
				Dim UpdateCommand12 As SqlCommand = new SqlCommand()
        UpdateCommand12.Connection = myConnection
        
				UpdateCommand12.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_12.text + "', '" + lname_12.text + "', '" + fname_12.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand12.ExecuteNonQuery()													
						

			  ' grab the PK	12
        Dim APK12 As String = "SELECT applicant_id from Applicants where email = '" + email_12.text + "'"

        Dim da12 as New SqlDataAdapter(APK12, ConnectionString)
        Dim ds12 as New DataSet("applicant_id")
		    da12.Fill(ds12, "applicant_id")
		    Dim pk12 as String = ds12.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk12) 'print to screen the pk12

			  Dim InsertCatAppJob12 As SqlCommand = new SqlCommand()
        InsertCatAppJob12.Connection = myConnection
        
				InsertCatAppJob12.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk12 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob12.ExecuteNonQuery()
				
end if

if email_13.text <> "" then
				
        'begin insert 13
				
				Dim UpdateCommand13 As SqlCommand = new SqlCommand()
        UpdateCommand13.Connection = myConnection
        
				UpdateCommand13.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_13.text + "', '" + lname_13.text + "', '" + fname_13.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand13.ExecuteNonQuery()													
						

			  ' grab the PK	13
        Dim APK13 As String = "SELECT applicant_id from Applicants where email = '" + email_13.text + "'"

        Dim da13 as New SqlDataAdapter(APK13, ConnectionString)
        Dim ds13 as New DataSet("applicant_id")
		    da13.Fill(ds13, "applicant_id")
		    Dim pk13 as String = ds13.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk13) 'print to screen the pk13

			  Dim InsertCatAppJob13 As SqlCommand = new SqlCommand()
        InsertCatAppJob13.Connection = myConnection
        
				InsertCatAppJob13.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk13 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob13.ExecuteNonQuery()
				
end if

if email_14.text <> "" then
				
        'begin insert 14
				
				Dim UpdateCommand14 As SqlCommand = new SqlCommand()
        UpdateCommand14.Connection = myConnection
        
				UpdateCommand14.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_14.text + "', '" + lname_14.text + "', '" + fname_14.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand14.ExecuteNonQuery()													
						

			  ' grab the PK	14
        Dim APK14 As String = "SELECT applicant_id from Applicants where email = '" + email_14.text + "'"

        Dim da14 as New SqlDataAdapter(APK14, ConnectionString)
        Dim ds14 as New DataSet("applicant_id")
		    da14.Fill(ds14, "applicant_id")
		    Dim pk14 as String = ds14.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk14) 'print to screen the pk14

			  Dim InsertCatAppJob14 As SqlCommand = new SqlCommand()
        InsertCatAppJob14.Connection = myConnection
        
				InsertCatAppJob14.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk14 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob14.ExecuteNonQuery()
				
end if

if email_15.text <> "" then
				
        'begin insert 15
				
				Dim UpdateCommand15 As SqlCommand = new SqlCommand()
        UpdateCommand15.Connection = myConnection
        
				UpdateCommand15.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_15.text + "', '" + lname_15.text + "', '" + fname_15.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand15.ExecuteNonQuery()													
						

			  ' grab the PK	15
        Dim APK15 As String = "SELECT applicant_id from Applicants where email = '" + email_15.text + "'"

        Dim da15 as New SqlDataAdapter(APK15, ConnectionString)
        Dim ds15 as New DataSet("applicant_id")
		    da15.Fill(ds15, "applicant_id")
		    Dim pk15 as String = ds15.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk15) 'print to screen the pk15

			  Dim InsertCatAppJob15 As SqlCommand = new SqlCommand()
        InsertCatAppJob15.Connection = myConnection
        
				InsertCatAppJob15.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk15 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob15.ExecuteNonQuery()
				
end if

if email_16.text <> "" then
				
        'begin insert 16
				
				Dim UpdateCommand16 As SqlCommand = new SqlCommand()
        UpdateCommand16.Connection = myConnection
        
				UpdateCommand16.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_16.text + "', '" + lname_16.text + "', '" + fname_16.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand16.ExecuteNonQuery()													
						

			  ' grab the PK	16
        Dim APK16 As String = "SELECT applicant_id from Applicants where email = '" + email_16.text + "'"

        Dim da16 as New SqlDataAdapter(APK16, ConnectionString)
        Dim ds16 as New DataSet("applicant_id")
		    da16.Fill(ds16, "applicant_id")
		    Dim pk16 as String = ds16.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk16) 'print to screen the pk16

			  Dim InsertCatAppJob16 As SqlCommand = new SqlCommand()
        InsertCatAppJob16.Connection = myConnection
        
				InsertCatAppJob16.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk16 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob16.ExecuteNonQuery()
				
end if

if email_17.text <> "" then
				
        'begin insert 17
				
				Dim UpdateCommand17 As SqlCommand = new SqlCommand()
        UpdateCommand17.Connection = myConnection
        
				UpdateCommand17.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_17.text + "', '" + lname_17.text + "', '" + fname_17.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand17.ExecuteNonQuery()													
						

			  ' grab the PK	17
        Dim APK17 As String = "SELECT applicant_id from Applicants where email = '" + email_17.text + "'"

        Dim da17 as New SqlDataAdapter(APK17, ConnectionString)
        Dim ds17 as New DataSet("applicant_id")
		    da17.Fill(ds17, "applicant_id")
		    Dim pk17 as String = ds17.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk17) 'print to screen the pk17

			  Dim InsertCatAppJob17 As SqlCommand = new SqlCommand()
        InsertCatAppJob17.Connection = myConnection
        
				InsertCatAppJob17.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk17 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob17.ExecuteNonQuery()
				
end if

if email_18.text <> "" then
				
        'begin insert 18
				
				Dim UpdateCommand18 As SqlCommand = new SqlCommand()
        UpdateCommand18.Connection = myConnection
        
				UpdateCommand18.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_18.text + "', '" + lname_18.text + "', '" + fname_18.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand18.ExecuteNonQuery()													
						

			  ' grab the PK	18
        Dim APK18 As String = "SELECT applicant_id from Applicants where email = '" + email_18.text + "'"

        Dim da18 as New SqlDataAdapter(APK18, ConnectionString)
        Dim ds18 as New DataSet("applicant_id")
		    da18.Fill(ds18, "applicant_id")
		    Dim pk18 as String = ds18.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk18) 'print to screen the pk18

			  Dim InsertCatAppJob18 As SqlCommand = new SqlCommand()
        InsertCatAppJob18.Connection = myConnection
        
				InsertCatAppJob18.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk18 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob18.ExecuteNonQuery()
				
end if

if email_19.text <> "" then
				
        'begin insert 19
				
				Dim UpdateCommand19 As SqlCommand = new SqlCommand()
        UpdateCommand19.Connection = myConnection
        
				UpdateCommand19.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_19.text + "', '" + lname_19.text + "', '" + fname_19.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand19.ExecuteNonQuery()													
						

			  ' grab the PK	19
        Dim APK19 As String = "SELECT applicant_id from Applicants where email = '" + email_19.text + "'"

        Dim da19 as New SqlDataAdapter(APK19, ConnectionString)
        Dim ds19 as New DataSet("applicant_id")
		    da19.Fill(ds19, "applicant_id")
		    Dim pk19 as String = ds19.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk19) 'print to screen the pk19

			  Dim InsertCatAppJob19 As SqlCommand = new SqlCommand()
        InsertCatAppJob19.Connection = myConnection
        
				InsertCatAppJob19.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk19 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob19.ExecuteNonQuery()
				
end if

if email_20.text <> "" then
				
        'begin insert 20
				
				Dim UpdateCommand20 As SqlCommand = new SqlCommand()
        UpdateCommand20.Connection = myConnection
        
				UpdateCommand20.CommandText = "INSERT INTO Applicants(email, lname, fname, state) VALUES ('" + email_20.text + "', '" + lname_20.text + "', '" + fname_20.text + "', '" + state.SelectedItem.Value + "')"				

        UpdateCommand20.ExecuteNonQuery()													
						

			  ' grab the PK	20
        Dim APK20 As String = "SELECT applicant_id from Applicants where email = '" + email_20.text + "'"

        Dim da20 as New SqlDataAdapter(APK20, ConnectionString)
        Dim ds20 as New DataSet("applicant_id")
		    da20.Fill(ds20, "applicant_id")
		    Dim pk20 as String = ds20.Tables(0).Rows(0).Item("Applicant_id")	
		
		    'Response.Write(pk20) 'print to screen the pk20

			  Dim InsertCatAppJob20 As SqlCommand = new SqlCommand()
        InsertCatAppJob20.Connection = myConnection
        
				InsertCatAppJob20.CommandText = "INSERT INTO catappjob (category_id, applicant_id, job_board_id) VALUES ('" + category.SelectedItem.Value + "', '" + pk20 + "', '" + jobboard.SelectedItem.Value + "')"				

        InsertCatAppJob20.ExecuteNonQuery()

end if			

myConnection.Close()	

Response.Redirect("Master_data_entry_3.aspx")

		end sub		

		
</script>

<html>
<head>
<title>Data Entry Form</title>
<link rel=StyleSheet href="coolstyle.css" type="text/css" media="screen">
</head>
<body>

<form runat="server">
<table align="center" border="0" bordercolor="c0c0c0" cellpadding="0" cellspacing='2'>
<tr>
<td></td><td></td><td colspan="3" align="center">
<h2><b>Data Entry Form</h2>
<asp:RequiredFieldValidator runat="server" ControlToValidate="email_1" ErrorMessage="You must enter an email address in the first email field" />
<table border="0">
<tr>
<td align="center">State</td><td align="center">Category</td><td align="center">Job Board</td>
</tr>
<tr>
<td><asp:DropDownList id="state" runat="server">
<asp:ListItem value="1">Alabama</asp:ListItem>
<asp:ListItem value="2">Alaska</asp:ListItem>
<asp:ListItem value="3">Arizona</asp:ListItem>
<asp:ListItem value="4">Arkansas</asp:ListItem>
<asp:ListItem value="5">California</asp:ListItem>
<asp:ListItem value="6">Colorado</asp:ListItem>
<asp:ListItem value="7">Connecticut</asp:ListItem>
<asp:ListItem value="8">Delaware</asp:ListItem>
<asp:ListItem value="9">Florida</asp:ListItem>
<asp:ListItem value="10">Georgia</asp:ListItem>
<asp:ListItem value="11">Hawaii</asp:ListItem>
<asp:ListItem value="12">Idaho</asp:ListItem>
<asp:ListItem value="13">Illinois</asp:ListItem>
<asp:ListItem value="14">Indiana</asp:ListItem>
<asp:ListItem value="15">Iowa</asp:ListItem>
<asp:ListItem value="16">Kansas</asp:ListItem>
<asp:ListItem value="17">Kentucky</asp:ListItem>
<asp:ListItem value="18">Louisiana</asp:ListItem>
<asp:ListItem value="19">Maine</asp:ListItem>
<asp:ListItem value="20">Maryland</asp:ListItem>
<asp:ListItem value="21">Massachusetts</asp:ListItem>
<asp:ListItem value="22">Michigan</asp:ListItem>
<asp:ListItem value="23">Minnesota</asp:ListItem>
<asp:ListItem value="24">Mississippi</asp:ListItem>
<asp:ListItem value="25">Missouri</asp:ListItem>
<asp:ListItem value="26">Montana</asp:ListItem>
<asp:ListItem value="27">Nebraska</asp:ListItem>
<asp:ListItem value="28">Nevada</asp:ListItem>
<asp:ListItem value="29">New Hampshire</asp:ListItem>
<asp:ListItem value="30">New Jersey</asp:ListItem>
<asp:ListItem value="31">New Mexico</asp:ListItem>
<asp:ListItem value="32">New York</asp:ListItem>
<asp:ListItem value="33">North Carolina</asp:ListItem>
<asp:ListItem value="34">North Dakota</asp:ListItem>
<asp:ListItem value="35">Ohio</asp:ListItem>
<asp:ListItem value="36">Oklahoma</asp:ListItem>
<asp:ListItem value="37">Oregon</asp:ListItem>
<asp:ListItem value="38">Pennsylvania</asp:ListItem>
<asp:ListItem value="39">Rhode Island</asp:ListItem>
<asp:ListItem value="40">South Carolina</asp:ListItem>
<asp:ListItem value="41">South Dakota</asp:ListItem>
<asp:ListItem value="42">Tennessee</asp:ListItem>
<asp:ListItem value="43">Texas</asp:ListItem>
<asp:ListItem value="44">Utah</asp:ListItem>
<asp:ListItem value="45">Vermont</asp:ListItem>
<asp:ListItem value="46">Virginia</asp:ListItem>
<asp:ListItem value="47">Washington</asp:ListItem>
<asp:ListItem value="48">West Virginia</asp:ListItem>
<asp:ListItem value="49">Wisconsin</asp:ListItem>
<asp:ListItem value="50">Wyoming</asp:ListItem>
<asp:ListItem value="51">D.C.</asp:ListItem>							
</asp:DropDownList></td>
<td><asp:DropDownList id="category" runat="server">
   <asp:ListItem value="21">customer s.</asp:ListItem>
   <asp:ListItem value="22">restaurant</asp:ListItem>
   <asp:ListItem value="23">marketing</asp:ListItem>
   <asp:ListItem value="24">management</asp:ListItem>
   <asp:ListItem value="25">arts</asp:ListItem>
   <asp:ListItem value="26">banking</asp:ListItem>
   <asp:ListItem value="27">retail</asp:ListItem>
   <asp:ListItem value="28">sales</asp:ListItem>
   <asp:ListItem value="29">adv</asp:ListItem>
   <asp:ListItem value="30">clerical</asp:ListItem>	
</asp:DropDownList></td>
<td><asp:DropDownList id="jobboard" runat="server">
   <asp:ListItem value="1">Monster</asp:ListItem>
   <asp:ListItem value="2">HotJobs</asp:ListItem>
</asp:DropDownList></td>
</tr>
</table>
</td>
</tr>
<tr>
<td></td>
<td align="right"></td>
<td align="center">Email</td>
<td align="center">First Name</td>
<td align="center">Last Name</td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_1" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">1:</td>
<td><asp:TextBox id="email_1" runat="server"/></td>
<td><asp:TextBox id="fname_1" runat="server"/></td>
<td><asp:TextBox id="lname_1" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_2" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">2:</td>
<td><asp:TextBox id="email_2" runat="server"/></td>
<td><asp:TextBox id="fname_2" runat="server"/></td>
<td><asp:TextBox id="lname_2" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_3" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">3:</td>
<td><asp:TextBox id="email_3" runat="server"/></td>
<td><asp:TextBox id="fname_3" runat="server"/></td>
<td><asp:TextBox id="lname_3" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_4" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">4:</td>
<td><asp:TextBox id="email_4" runat="server"/></td>
<td><asp:TextBox id="fname_4" runat="server"/></td>
<td><asp:TextBox id="lname_4" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_5" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">5:</td>
<td><asp:TextBox id="email_5" runat="server"/></td>
<td><asp:TextBox id="fname_5" runat="server"/></td>
<td><asp:TextBox id="lname_5" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_6" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">6:</td>
<td><asp:TextBox id="email_6" runat="server"/></td>
<td><asp:TextBox id="fname_6" runat="server"/></td>
<td><asp:TextBox id="lname_6" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_7" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">7:</td>
<td><asp:TextBox id="email_7" runat="server"/></td>
<td><asp:TextBox id="fname_7" runat="server"/></td>
<td><asp:TextBox id="lname_7" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_8" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">8:</td>
<td><asp:TextBox id="email_8" runat="server"/></td>
<td><asp:TextBox id="fname_8" runat="server"/></td>
<td><asp:TextBox id="lname_8" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_9" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">9:</td>
<td><asp:TextBox id="email_9" runat="server"/></td>
<td><asp:TextBox id="fname_9" runat="server"/></td>
<td><asp:TextBox id="lname_9" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_10" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">10:</td>
<td><asp:TextBox id="email_10" runat="server"/></td>
<td><asp:TextBox id="fname_10" runat="server"/></td>
<td><asp:TextBox id="lname_10" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_11" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">11:</td>
<td><asp:TextBox id="email_11" runat="server"/></td>
<td><asp:TextBox id="fname_11" runat="server"/></td>
<td><asp:TextBox id="lname_11" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_12" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">12:</td>
<td><asp:TextBox id="email_12" runat="server"/></td>
<td><asp:TextBox id="fname_12" runat="server"/></td>
<td><asp:TextBox id="lname_12" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_13" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">13:</td>
<td><asp:TextBox id="email_13" runat="server"/></td>
<td><asp:TextBox id="fname_13" runat="server"/></td>
<td><asp:TextBox id="lname_13" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_14" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">14:</td>
<td><asp:TextBox id="email_14" runat="server"/></td>
<td><asp:TextBox id="fname_14" runat="server"/></td>
<td><asp:TextBox id="lname_14" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_15" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">15:</td>
<td><asp:TextBox id="email_15" runat="server"/></td>
<td><asp:TextBox id="fname_15" runat="server"/></td>
<td><asp:TextBox id="lname_15" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_16" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">16:</td>
<td><asp:TextBox id="email_16" runat="server"/></td>
<td><asp:TextBox id="fname_16" runat="server"/></td>
<td><asp:TextBox id="lname_16" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_17" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">17:</td>
<td><asp:TextBox id="email_17" runat="server"/></td>
<td><asp:TextBox id="fname_17" runat="server"/></td>
<td><asp:TextBox id="lname_17" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_18" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">18:</td>
<td><asp:TextBox id="email_18" runat="server"/></td>
<td><asp:TextBox id="fname_18" runat="server"/></td>
<td><asp:TextBox id="lname_18" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_19" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">19:</td>
<td><asp:TextBox id="email_19" runat="server"/></td>
<td><asp:TextBox id="fname_19" runat="server"/></td>
<td><asp:TextBox id="lname_19" runat="server"/></td>
</tr>
<tr>
<td align="right"><asp:RegularExpressionValidator runat="server" ControlToValidate="email_20" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="Please Enter a Valid Email" /></td>
<td align="right">20:</td>
<td><asp:TextBox id="email_20" runat="server"/></td>
<td><asp:TextBox id="fname_20" runat="server"/></td>
<td><asp:TextBox id="lname_20" runat="server"/></td>
</tr>
<tr>
<td colspan="2"></td>				
<td colspan="3" align="center"><br><asp:button id="tbSubmit" Text="Submit" runat="server" onClick="doInsert" /></td>
<asp:label id="doMessage" runat="server"/>	
</tr></table>
</form>
</body></html>
 
opps, I just noticed that not all the code got copied, if anyone needs the rest, I will post it.

tia...mike
 
All you need to do is use the SelectedIndexChanged event of the first dropdownlist to get it's value and populate the second list accordingly.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Here is how I ended up doing it.

Code:
   Sub page_load(sender as Object, e as EventArgs)

    if NOT IsPostBack() then	 
	 
        Dim myConnection1 As New SqlConnection(ConnectionString)
				
				Dim getJobBoard As String = "SELECT job_board_id, job_board from job_board"
				
				Dim jda as New SqlDataAdapter(getJobBoard, myConnection1)
               
        Dim DS As New DataSet
				
        myConnection1.Open()
				
        jda.Fill(DS)
				
        myConnection1.Close()
				
        jobboard.DataSource = DS.Tables(0)
        jobboard.DataTextField = "job_board"
        jobboard.DataValueField = "job_board_id"
        jobboard.DataBind()


    end if
				
    end sub		
		
		
		sub Category_SelectedIndexChanged(sender as Object, e as EventArgs)		
		
        Dim myConnection2 As New SqlConnection(ConnectionString)
				
				Dim getCategory As String = "SELECT category_id, category from categories where job_board_id = '" + jobboard.SelectedItem.Value + "'"
				
				Dim cda as New SqlDataAdapter(getCategory, myConnection2)
               
        Dim CS As New DataSet
				
        myConnection2.Open()
				
        cda.Fill(CS)
				
        myConnection2.Close()
				
        category.DataSource = CS.Tables(0)
        category.DataTextField = "category"
        category.DataValueField = "category_id"
        category.DataBind()		


		end sub

The list box code.

Code:
<td><asp:DropDownList id="jobboard" runat="server" Rows="1" EnableViewState="True"  autopostback
onSelectedIndexChanged="Category_SelectedIndexChanged" 
DataTextField="job_board" DataValueField="job_board_id">
</asp:DropDownList></td>
<td><asp:DropDownList id="category" runat="server"  EnableViewState="True"></asp:DropDownList></td>

Any suggestions on improving this?

tia... mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top