listbox, textbox bind

Jun 11 2004 12:19 PM
Can someone please tell me how to bind the listBox to a textbox? In my code below, I have a listBox1, which is bound to a data table and displays a list of last names. I bound the selected value to email address, just because this is the primary key in the table. Below the listbox, I have a textbox, which supposed to display all other fields in the row, that is selected in the listBox. I thought if I could get the datatable to return the id for the row, I could entered that in the text box section like, dt_shared.Rows[returnedid][i].ToString() Is there a default id for a datarow in a datatable, and if yes how can I get it? And how can I then bind the listbox to the textbox? If not how can I bind the listbox to the textbox? listBox1.DataSource = dt_shared; listBox1.DisplayMember = "LastName"; listBox1.ValueMember = "Email1Address"; listBox1.DataBindings.Add("SelectedValue",dt_shared,"Email1Address"); String str = ""; for(int i=0; i< dt_shared.Columns.Count; i++) { if(dt_shared.Rows[?][i].ToString() != null) { str = str + dt_shared.Rows[?][i].ToString() + "\r\n"; } } textBox1.Text = str; Thank you Marika