养个男孩当宠物:asp.net中dropdownlist如何绑定,

来源:百度文库 编辑:高考问答 时间:2024/04/30 09:33:01
我的代码如下,哪有错呢,代码输出,说明没有绑定成功或者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="..." /// ... 为某个字段名