drop down list depending on first drop down list

May 19 2005 10:24 AM
Hi all, I am building a projet were I have two drop down list, I want the second one to depend on the entry from the first one. My data is in a SQL db. All in the same table but in different columns. I can get the first ddl to work fine but the second one doesn't seem to work. Any help would be greatly appreciated, it's my second week coding in vb.net so pretty new at this. HEre's what i've got... (Pub_Name and Pub_title are columns in my db I want the Pub_title that will be in the second ddl to have as Pub_Name the one that was chosen in the first ddl. ) Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged 'saves the changed value of the drop-down list in the string PubName Dim PubName As String PubName = DropDownList1.SelectedItem.Text txtCategoryName.Text = PubName.ToString Dim dreader2 As SqlClient.SqlDataReader SqlConnection1.Open() SqlCommand2.CommandText = "SELECT Pub_title FROM Publishers WERE Pub_Name = PubName" dreader2 = SqlCommand2.ExecuteReader() ddltitle.Items.Add("Make a selection") While dreader2.Read() ddltitle.Items.Add(New ListItem(dreader2(0).ToString())) End While dreader2.Close() SqlConnection1.Close() End Sub ************************** ANy help would be greatly appreciated. I have created my connection, data adapter and command from the toolbox on my .aspx page.