>>> Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged >>> Session("CurrentList") = ListBox1.SelectedValue >>> Dim sql As String >>> sql = "SELECT list_members.list_id, list_members.personid, " >>> sql += " list_members.persontag, maillist.lname, " >>> sql += " maillist.fname + maillist.middle + maillist.lname + maillist.suffix + ', ' + maillist.company AS name" >>> sql += " FROM list_members " >>> sql += " LEFT JOIN maillist ON list_members.personID = maillist.personID " >>> sql += " WHERE list_members.list_id =" & Session("CurrentList").ToString >>> sql += " ORDER BY lname" >>> SqlDataSource3.SelectCommand = sql >>> lblOwner.Text = ListBox1.SelectedValue >>> End Sub >>>>>>The user makes a choice in Listbox1 that controls the contents of Listbox3 via the above code. (Note the reset of the SelectCommand.) So I really don't need to return a value from the new record. I just need to make sure its included in the selection set.
>>>>> Protected Sub cmdAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAdd.Click >>>>> Dim sql As String = "INSERT into list_members (list_ID, personID) VALUES " >>>>> sql += "(" & Session("CurrentList").ToString & "," & ListBox2.SelectedValue.ToString & ")" >>>>> SqlDataSource3.InsertCommand = sql >>>>> SqlDataSource3.Insert() >>>>> SqlDataSource3.Select(DataSourceSelectArguments.Empty) >>>>> ListBox3.DataBind() >>>>> lblOwner.Text = sql >>>>> End Sub >>>>>>>>>>
>>>>>>> Protected Sub cmdAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAdd.Click >>>>>>> Dim sql As String = "INSERT into list_members (list_ID, personID) VALUES " >>>>>>> sql += "(" & Session("CurrentList").ToString & "," & ListBox2.SelectedValue.ToString & ")" >>>>>>> SqlDataSource3.InsertCommand = sql >>>>>>> SqlDataSource3.Insert() >>>>>>> SqlDataSource3.Select() ' This line presents an error and may not belong >>>>>>> ListBox3.DataBind() >>>>>>> End Sub >>>>>>>>>>>>>>