リスト ボックスの選択した項目の値を取得するにはどうすればよいですか?
私はこのようなことを試しました:
foreach (var item in combo_course_op.SelectedItems)
{
string s = "select cid from tms_course where course_title = '" + item.ToString() + "'";
}
しかし、機能しません..文字列が「tms_courseからcidを選択してください。ここでcourse_title = 'System.Data.DataRowView'」と表示されます
私はどこで間違っていますか?
これは私がデータバインドした方法です:
MyCommand = new OdbcCommand("select distinct module_name from tms_class_schedule where class_date ='"+selectedDate+"'", DBConnect.MyConnection);
dap = new OdbcDataAdapter(MyCommand);
DS = new DataSet();
dap.SelectCommand = MyCommand;
dap.Fill(DS);
combo_course_op.DataContext = DS.Tables[0].DefaultView;
combo_course_op.DisplayMemberPath = DS.Tables[0].Columns["module_name"].ToString();