combo box linked to datagrid
-
I'm trying to learn and have a problem selecting an author from the combo box and pulling up that particular authors book info in a datagrid. Can someone please help on the Selected Index changed to pull up info in data grid. I can't bind them together. Would appreciate so much!!!!!!!!!!!!!!!!! Alex Below is code: 'Call up authors name in combo box cmdAuthors.CommandText = "Select au_id, au_fname + ' ' + au_lname as name From authors" cmdAuthors.CommandType = CommandType.Text cmdAuthors.Connection = conPubs conPubs.Open() 'cboAuthors.DataTextField = paraName.Value daAuthors.Fill(dsPubs, "Authors") conPubs.Close() 'show the names in the combo box cboAuthors.DataSource = dsPubs.Tables("Authors") cboAuthors.DataTextField = "name" cboAuthors.DataValueField = "au_id" cboAuthors.DataBind() End Sub Private Sub cboAuthors_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboAuthors.SelectedIndexChanged Dim conPubs As New SqlConnection("Server=alex; Database= pubs; UID= sa; PWD= ") Dim cmdTitles As New SqlCommand Dim drTitles As SqlDataReader Dim daTitles As New SqlDataAdapter(cmdTitles) Dim dsPubs_Titles As New DataSet cmdTitles.CommandText = "Select title, title_ID, pub_id, pubdate From Titles Where authors.au_id = titles.title_id ORDER BY titles.title" cmdTitles.CommandType = CommandType.Text cmdTitles.Connection = conPubs If Not IsPostBack Then conPubs.Open() End If dgTitles.DataSource = dsPubs_Titles drTitles = cmdTitles.ExecuteReader dgTitles.DataSource = drTitles dgTitles.DataBind() daTitles.Fill(dsPubs_Titles, "Titles") conPubs.Close() End Sub End Class