datagridview绑定问题,在线等
请问我要将数据库里面的每个字段和datagridview我自己添加的字段绑定应该怎么弄?
datagridview1.databindings.add(headertext,ds, "student.sno ")
还是
datagridview1.databindings.add(name,ds, "student.sno ")
还是别的什么办法?
------解决方案--------------------dv = new DataView(ds.Tables[ "Material "]);
dgvMaterial.AutoGenerateColumns = false;
dgvMaterial.DataSource = dv;
MaterialNo.DataPropertyName = "MaterialNo ";
MaterialName.DataPropertyName = "MaterialName ";
Color.DataPropertyName = "Color ";
MaterialTypeName.DataPropertyName = "MaterialTypeName ";
Spec.DataPropertyName = "Spec ";
dgvMaterial.ReadOnly = true;