如何使用Dataset实现对Dropdownlist的赋值?
如何使用Dataset实现对Dropdownlist的赋值?
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
'调出系部名称
dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myCommand As New SqlDataAdapter("select * from [Department]", myConnection)
Dim ds As New DataSet()
myCommand.Fill(ds, "Department")
'将系部名称赋值给系部设置
D_Name.DataSource =ds.Tables("Department")
D_Name.DataTextField="D_Name"
D_Name.DataValueField ="D_ID"
D_Name.DataBind()
myConnection.close()
End sub