DataRow[] dr = _deptCodeDt.Select(string.Format(" ward_code = '{0}'", LocalSetting.WardCode)); if (dr.Length <= 0) return; DataTable tempT = new DataTable(); tempT = dr[0].Table.Clone(); //克隆表结构 DataSet tempDs = new DataSet(); tempDs.Tables.Add(tempT); //添加到辅助数据集中 tempDs.Merge(dr); //利用数据集合并行集到表 deptCmBox.DataSource = tempDs.Tables[0]; deptCmBox.DisplayMember = "ward_name"; deptCmBox.ValueMember = "ward_code";
备注:1._deptCodeDt 为从数据中中返回的DataTable
2.deptCmBox 是一个下拉列表空间的name