在comboBox中显示数据 [英] show data in comboBox
本文介绍了在comboBox中显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您能告诉我如何从数据库显示数据到comboBox吗?:)
can u tell me how to show data from database to comboBox??:)
推荐答案
转到此处:
MSDN:组合框类 [
Go here:
MSDN: ComboBox Class[^]
Read all about them!
从数据库获取数据,然后按如下所示分配给Combobox.
Get Data from database then assign to Combobox as below.
Dropdownlist1.DataSource = dtTemp; //Sample Datatable which contains data
Dropdownlist1.DataBind();
Dropdownlist1.DataTextField = "EmployeeName";
Dropdownlist1.DataValueField = "EmployeeID";
助手,您必须具备C#书籍才能了解其中的基本知识.祝您编码愉快.
Mate, you must need C# Book for your basic knowledge in that. Happy coding.
''选择idfield作为ID,namefield作为表中的Name
之后将查询结果填充到数据集
组合框.数据源= dataset.tables(0)
cmbDrCr.DisplayMember ="ID"
cmbDrCr.ValueMember =名称"
''select idfield as ID, namefield as Name from table
fill t result of query to a dataset after that
combobox. datasource =dataset.tables(0)
cmbDrCr.DisplayMember="ID"
cmbDrCr.ValueMember="Name"
这篇关于在comboBox中显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文