I have two listbox’s. One is filled by Users.
daUsers = new SqlDataAdapter("SELECT * FROM Users", connection);
daUsers.Fill(UsersLocal);
listBox2.DataSource = UsersLocal;
listBox2.DisplayMember = "Name";
listBox2.ValueMember = "ID";
Second is filled by documents. In document dataTable I’m storing same data wit UserID.
Now I want to bind second list box with data from Document DataTable where UserID is from first ListBox. How I can do that? I tried by SQLCommand but it failed.
daDocuments = new SqlDataAdapter("SELECT * FROM Documents WHERE UserID='listbox2.SelectedValue'", connection);
Then use this
stringto assign data to your documentListBox.