我定义了String
的全局数组,我在2个按钮的点击事件中使用它。
Dim arrPoliciesNumber() As String = New String() {}
并在第一个按钮点击事件中,我将值插入数组
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
If MultipleData.Value <> "" Then
Dim _Data = MultipleData.Value.Split(vbLf)
arrPoliciesNumber = MultipleData.Value.Split(vbLf)
For Each _Text In _Data
_SearchList1Value = _SearchList1Value + _Text.Trim + "','"
Next
_SearchList1Value = Left(_SearchList1Value, _SearchList1Value.Length - 3)
_SearchList1Value = "'" + _SearchList1Value + "'"
Else
If txtSearch1.Text.Trim <> "" Then
_SearchList1Value = txtSearch1.Text
arrPoliciesNumber = New String(0) {}
arrPoliciesNumber(0) = New String(txtSearch1.Text)
_SearchList1Value = "'" + _SearchList1Value + "'"
End If
End If
现在在另一个按钮点击事件我试图在数组中获取插入的字符串,但我发现它为空,长度= 0
If arrPoliciesNumber.Length > 0 Then
'here we need to add the report parameter with report ID
For Each policyNo As String In arrPoliciesNumber
_DB.AddReportRequestParameter(reportId, policyNo)
Next
End If
我如何保持数组中插入的值?提前谢谢。