具有DisplayMember和ValueMember的ComboBox的人口 [英] Population of ComboBox with DisplayMember and ValueMember
本文介绍了具有DisplayMember和ValueMember的ComboBox的人口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想这样填充Combox:
I am trying to populate Combox like this :
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("SELECT id,name FROM table1", con);
da.Fill(ds, "FillDropDown");
comboProject.DisplayMember = "FillDropDown.name";
comboProject.ValueMember = "FillDropDown.id";
comboProject.DataSource = ds.Tables["FillDropDown"];
但是所有项目都在Combobox中显示为System.Data.DataRowView。为什么会是这样?
感谢提前。
But all item are showing as "System.Data.DataRowView" in Combobox. why it is like that? Thanks in Advance.
推荐答案
try comboProject.DataSource = ds.Tables["FillDropDown"].DefaultView;
这篇关于具有DisplayMember和ValueMember的ComboBox的人口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文