刘子波军长简历:asp.net中dropdownlist如何绑定,

来源:百度文库 编辑:神马品牌网 时间:2024/05/14 06:08:22
我的代码如下,哪有错呢,代码输出,说明没有绑定成功或者reader没成功
connection.Open();
SqlCommand command=new SqlCommand("select GovernmentAgency.GovName from GovernmentAgency,PublicFile where GovernmentAgency.GovCode=PublicFile.GovCode",connection);
SqlDataReader reader = command.ExecuteReader();
drop.DataSource= reader;
drop.DataBind()

drop.DataBind()前面加上
drop.DataTextField="..." /// ... 为某个字段名
drop.DataTextValue="..." /// ... 为某个字段名