dropdownlist 绑定(ASP.NET 中dropdownlist的绑定问题)
ASP.NET 中dropdownlist的绑定问题?
网友:聂風 提问
SqlConnection con = new SqlConnection(“server=.;database=login;uid=sa;pwd=;”); con.Open(); DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(“select * from Met where usermet='” + Label11.Text + “‘”, con); da.Fill(ds, “username”); DropDownList1.DataSource = ds; DropDownList1.DataMember = “username”; DropDownList1.DataBind();
为什么总是显示再dropdownlist里面是“System.Data.DataRowView”???
五星知识达人网友:杯酒困英雄 解答于 2022-06-06 01:19
把DropDownList1.DataMember = “username”; 改成DropDownList1.DataTextField = “username”; 就可以了
1楼网友:舊物识亽 解答于 2022-02-06 01:55
this.dropdownlist1.datasource=方法名(返回list或ilist类型);
this.dropdownlist1.datatestfield=”名称”; this.dropdownlist1.datavaluefield=”id”;
this.dropdownlist1.databind();
本文地址:https://www.cubemovie.cn/hetong/48507.html