看看这个过程如何往里传进参数?DropDownList数组附值的有关问题
看看这个过程怎么往里传进参数??DropDownList数组附值的问题
DropDownList数组附值的问题
Shared Function FillList(ByVal strDest() As DropDownList)
Dim i As Integer
For i = LBound(strDest) To UBound(strDest)
strDest(i).Items.Add( "ddd ")
Next
End Function
strDest() 是几个DropDownList。怎么把它传进来呀,或着是说怎么给strDest()这个数组附值呀
------解决方案--------------------
<%@ Page Language= "VB " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<script runat= "server ">
Private Sub FillList(ByVal ddls() As DropDownList, ByVal i As Integer)
For j As Integer = 0 To i - 1
ddls(i).Items.Add( "ddd ")
Next
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim ddls(80) As DropDownList
Dim i As Integer
' 遍历Form1种的所有控件,从中找出所有的DropDownList控件
For Each ctrl As Control In Me.form1.Controls
If (ctrl.GetType.ToString = "System.Web.UI.WebControls.DropDownList ") Then
ddls(i) = ctrl
i += 1
End If
Next
'-----------------------------------------------
FillList(ddls, i)
End Sub
</script>
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> Untitled Page </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:DropDownList ID = "DropDownList1 " runat = "server " />
<asp:DropDownList ID = "DropDownList2 " runat = "server " />
<asp:DropDownList ID = "DropDownList3 " runat = "server " />
</div>
</form>
</body>
</html>
DropDownList数组附值的问题
Shared Function FillList(ByVal strDest() As DropDownList)
Dim i As Integer
For i = LBound(strDest) To UBound(strDest)
strDest(i).Items.Add( "ddd ")
Next
End Function
strDest() 是几个DropDownList。怎么把它传进来呀,或着是说怎么给strDest()这个数组附值呀
------解决方案--------------------
<%@ Page Language= "VB " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<script runat= "server ">
Private Sub FillList(ByVal ddls() As DropDownList, ByVal i As Integer)
For j As Integer = 0 To i - 1
ddls(i).Items.Add( "ddd ")
Next
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim ddls(80) As DropDownList
Dim i As Integer
' 遍历Form1种的所有控件,从中找出所有的DropDownList控件
For Each ctrl As Control In Me.form1.Controls
If (ctrl.GetType.ToString = "System.Web.UI.WebControls.DropDownList ") Then
ddls(i) = ctrl
i += 1
End If
Next
'-----------------------------------------------
FillList(ddls, i)
End Sub
</script>
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> Untitled Page </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:DropDownList ID = "DropDownList1 " runat = "server " />
<asp:DropDownList ID = "DropDownList2 " runat = "server " />
<asp:DropDownList ID = "DropDownList3 " runat = "server " />
</div>
</form>
</body>
</html>