[求助]关于控件绑定问题
string str_select = "select 专业ID=tb_SpecialtyInfo.t_specialtyID,专业名=tb_SpecialtyInfo.t_specialtyName,学习年制=tb_SpecialtyInfo.t_Year,院系名=tb_CollegeInfo.t_CollegeName,说明=tb_SpecialtyInfo.t_caption from tb_SpecialtyInfo,tb_CollegeInfo where tb_SpecialtyInfo.t_CollegeID=tb_CollegeInfo.t_CollegeID";string connString = ConfigurationManager.ConnectionStrings["connString"].ConnectionString;
SqlConnection conn = new SqlConnection(connString);
DataSet ds = new DataSet();
SqlDataAdapter da,da2;
da = new SqlDataAdapter(str_select ,conn);
da2 = new SqlDataAdapter("select t_CollegeName from tb_CollegeInfo",conn); //连接院系信息表
da.Fill(ds, "tb_SpecialtyInfo,tb_CollegeInfo");
da2.Fill(ds, "tb_CollegeInfo");
cBox_specialtyCD.DataSource = ds; //绑定tb_CollegeInfo表中的院系名字段
cBox_specialtyCD.DisplayMember = "tb_CollegeInfo.t_CollegeName";
Binding Bd_ID = new Binding("Text", ds, "tb_SpecialtyInfo.专业ID"); //绑定专业ID
this.txt_specialtyID.DataBindings.Clear(); //清除绑定信息
this.txt_specialtyID.DataBindings.Add(Bd_ID);
//Binding Bd_SName = new Binding("Text", ds, "tb_SpecialtyInfo.专业名"); //绑定专业名
//this.txt_specialtyName.DataBindings.Clear();
//this.txt_specialtyName.DataBindings.Add(Bd_SName);
//Binding Bd_NZ = new Binding("Text", ds, "tb_SpecialtyInfo.学习年制"); //绑定年制
//this.cBox_NZ.DataBindings.Clear();
//this.cBox_NZ.DataBindings.Add(Bd_NZ);
////Binding Bd_College = new Binding("Text", ds, "tb_SpecialtyInfo.院系名"); //绑定院系名
////this.cBox_specialtyCD.DataBindings.Clear();
////this.cBox_specialtyCD.DataBindings.Add(Bd_College);
//Binding Bd_caption = new Binding("Text", ds, "tb_SpecialtyInfo.说明"); //绑定说明
//this.txt_caption.DataBindings.Clear();
//this.txt_caption.DataBindings.Add(Bd_caption);
this.dGridV_specialty.DataSource = ds;
this.dGridV_specialty.DataMember = "tb_SpecialtyInfo,tb_CollegeInfo"; //绑定dGridV_specialty控件
MyBm = this.dGridV_specialty.BindingContext[ds, "tb_SpecialtyInfo,tb_CollegeInfo"];
提示这句话错误: Binding Bd_ID = new Binding("Text", ds, "tb_SpecialtyInfo.专业ID"); //绑定专业ID
错误提示:无法创建字段 tb_SpecialtyInfo 的子列表