0
早上好。 我有一個下拉列表控件,當選擇一個特定的項目時,另一個下拉列表將根據該選擇進行填充。後面的代碼如下。asp.net下拉控件的數據綁定列表
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
它正在讀取以創建列表屬性的文件格式如下; 玉米,小麥 , 咖啡
所以當主下拉選擇的項目是「未來」的第二下拉值數據綁定到所述FuturesList屬性。任何幫助,將不勝感激
我已經將屍體解剖背部設置爲真...我將處理它 – dinotom
可能需要刪除「If Not IsPostBack Then」 檢查 –
屍檢?我的.NET版本不這樣做。看起來有人在手機上有自動更正=真。 =) – Yatrix