早上好。I have a dropdown list control which when a particular item is selected, another dropdown's list is populated based on that selection. 后面的代码如下。
Imports System.IO
Partial Class Data
Inherits System.Web.UI.Page
Private Property _futureslist As List(Of String)
Property FuturesList As List(Of String)
Get
Return _futureslist
End Get
Set(value As List(Of String))
Dim strText As String = File.ReadAllText(HttpContext.Current.Server.MapPath("~/DataFiles/AvailableFutures.txt"))
Dim arytext() As String = strText.Split(",")
For i As Integer = 0 To arytext.Count - 1
value.Add(arytext(i))
Next
_futureslist = value
End Set
End Property
Protected Sub ddlMain_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlMain.SelectedIndexChanged
If Not IsPostBack Then
If ddlMain.SelectedItem.Text = "Futures" Then
ddlMainsub1.DataSource = _futureslist
ddlMainsub1.DataBind()
End If
End If
End Sub
End Class
它为创建列表属性而读取的文件格式如下;玉米、小麦、咖啡
因此,当主下拉选择项是“Futures”时,第二个下拉值将数据绑定到 FuturesList 属性。任何帮助,将不胜感激