手机如何提取图片文字:.NET中dropdownlist的问题

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/03 03:15:41
用dropdownlist绑定数据表中的两个字段"id","name"
DropDownList1.DataTextField = "name" 'dropdownlist的Text的字段
DropDownList1.DataValueField = "id" 'dropdownlist的Value的字段

运行后可见效果,但是当我下拉选择另一个name时,取不出当前name的Value值。

程序如下:
Dim conn As SqlConnection = DB.con()
Dim SQL_Select As String = "select id, username from [user]"
Dim myAdapter As New SqlDataAdapter(SQL_Select, conn)
conn.Open()
Dim dataSet As New DataSet
myAdapter.Fill(DataSet, "user")
conn.Close()
DropDownList1.DataSource = DataSet.Tables("user").DefaultView
DropDownList1.DataTextField = "username" DropDownList1.DataValueField = "id"
DropDownList1.DataBind()

dropdownlist的autopostback属性要设置为true,默认是false,然后你的selectindexchanged时间就生效了。

dropdownlist的autopostback属性要设置为true,默认是false,然后你的selectindexchanged时间就生效了。