如何在组合框中显示值,我得到的是“System.Data.DataRowView”而不是值
本文关键字:System Data DataRowView 组合 显示 | 更新日期: 2023-09-27 18:36:06
我想在组合框中从客户(表)中获取custid(column),但它不显示custid值,而是为每个值显示"System.Data.DataRowView"。我正在研究 asp.net,使用来自ajax工具包的任何mysql(wamp服务器)的comboBox。
string cs2 = "Server=localhost;Database=MyDB;Uid=root;Password=;";
MySqlConnection cn = new MySqlConnection(cs2);
cn.Open();
MySqlDataAdapter Mda = new MySqlDataAdapter("select custid from customer", cn);
DataSet ds = new DataSet();
Mda.Fill(ds, "customer");
ComboBox1.DataSource = ds.Tables["customer"];
ComboBox1.DataBind();
你必须
使用DataTextField
和/或DataValueField
属性:
<cc1:ComboBox
DataTextField="custid"
DataValueField="custid"
runat="server">
有关完整示例,请查看: http://www.asp.net/web-forms/overview/ajax-control-toolkit/combobox/how-do-i-use-the-combobox-control-cs