我定义了一个全局数组,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
我怎样才能将插入的值保留在数组中?提前致谢。