2012-12-27 3 views
0

두 개의 목록 상자가 있습니다. 하나는 사용자가 채 웁니다.데이터 세트를 목록 상자에 바인딩

daUsers = new SqlDataAdapter("SELECT * FROM Users", connection); 
daUsers.Fill(UsersLocal); 
listBox2.DataSource = UsersLocal; 
listBox2.DisplayMember = "Name"; 
listBox2.ValueMember = "ID"; 

두 번째는 문서로 채워집니다. 문서 dataTable에서 동일한 데이터 재치 UserID를 저장하고 있습니다. 이제 UserID가 첫 번째 ListBox의 Document DataTable의 데이터로 두 번째 목록 상자를 바인딩하려고합니다. 내가 어떻게 할 수 있니? SQLCommand에 의해 시도했지만 실패했습니다.

daDocuments = new SqlDataAdapter("SELECT * FROM Documents WHERE UserID='listbox2.SelectedValue'", connection); 

답변

0
string queryString = ("SELECT * FROM Documents WHERE UserID='" + listbox2.SelectedValue + "'"; 

그런 다음 문서 ListBox에 데이터를 할당하려면이 string를 사용합니다.

관련 문제