-2
嗨,我需要一些帮助,了解如何绑定到从vb.net函数生成的数组绑定。根据数组列表的位置()(函数内部或外部),我似乎遇到两个错误。寻找关于如何解决问题的建议,使用函数中的值填充下拉列表。由于asp dropdownlist via databinding to vb.net arraylist
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<br />
<asp:DropDownList ID="dd1" runat="server" AutoPostBack="True"></asp:DropDownList>
<br />
</body>
</html>
Imports System
Imports System.DirectoryServices
Imports System.DirectoryServices.ActiveDirectory
Partial Class _Default
Inherits System.Web.UI.Page
Public Function EnumerateDomains() As ArrayList
Dim DomainList As New ArrayList()
' DomainList As New ArrayList
Dim currentForest As Forest = Forest.GetCurrentForest()
Dim currentDomains As DomainCollection = currentForest.Domains
'Dim CurrentDomain As String
For Each currentDomain As Domain In currentDomains
DomainList.Add("currentDomain.Name")
Next
DomainList.TrimToSize()
DomainList.Sort()
Return DomainList
End Function
Protected Sub Selection_Changed(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
'DropDownList1.Items.Clear()
DropDownList1.DataSource=DomainList
DropDownList1.DataBind()
'DropDownList1.SelectedIndex=0
End If
End Sub
End Class
'DomainList.Add(“currentDomain.Name”)'不可能是正确的,每次迭代都会有同样的结果。它可能是'DomainList.Add(currentDomain.Name)' – OneFineDay 2014-11-09 01:35:51
尝试使用或不使用speachmarks,加载页面,但在采用该概念之后,列表不会出现 – Maverick 2014-11-09 11:46:46
,您更改答案并接受您的答案。 – HaveNoDisplayName 2014-11-14 17:41:26