如何解决此问题“无法绑定到DataSource上的属性或列firstname。参数名称:dataMember“ [英] How can solve this problem "Cannot bind to the property or column firstname on the DataSource. Parameter name: dataMember"
本文介绍了如何解决此问题“无法绑定到DataSource上的属性或列firstname。参数名称:dataMember“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码给我这个错误无法绑定到DataSource上的属性或列名字。
参数名称:dataMember
我的代码在这里:
my code give me this error "Cannot bind to the property or column firstname on the DataSource.
Parameter name: dataMember"
my code here :
da.SelectCommand = new SqlCommand("select * from student ",cs);
ds.Clear();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
this.textBox1.DataBindings.Add("Text", this.tblnamesbs, "firstname",true);
this.textBox2.DataBindings.Add("Text",this.tblnamesbs,"lastname",true);
推荐答案
< b> firstname 不存在于数据源this.tblnamesbs
。
在数据源中添加名字或检查它的拼写。它会解决...
i试用这段代码,工作正常..
firstname is not present in the datasourcethis.tblnamesbs
.
add first name in the datasource or check the spelling of it . it will resolve ...
i tried this code,its working fine..
DataTable tblnamesbs = new DataTable();
tblnamesbs.Columns.Add("firstname", typeof(string));
tblnamesbs.Rows.Add("one");
BindingSource binding = new BindingSource();
binding.DataSource = tblnamesbs;
this.textBox1.DataBindings.Add("Text",binding,"firstname" );
这篇关于如何解决此问题“无法绑定到DataSource上的属性或列firstname。参数名称:dataMember“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文