Hey all, i am new at the ViewState and i am looking to see what values are stored within it. I know how to loop through an array to check for a value but i do not know how to go about doing that for a ViewState("test") property.
Let's say i have added "bob, tom, Jim" to a ViewState called ViewState("test"). I would like to be able to see if "tom" was in the ViewState("test"). If not then add it but if it exists already then skip it.
Thanks!
David
THE CODE
Public strIDArray() As String
Public vsSaver As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
ViewState("vsSaver") = "0000770000"
Else
If (Not ViewState("vsSaver") Is Nothing) Then
strIDArray(strIDArray.Length) = CType(ViewState("vsSaver"), String)
End If
End If
end sub
Private Sub gvData_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvData.RowCommand
Dim idIndexNumber As Integer = Array.IndexOf(strIDArray, strID)
If Not ViewState("strIDArray").ToString().Contains(strID) Then
strIDArray(idIndexNumber + 1) = strID
ViewState("strIDArray") = CLng(ViewState("strIDArray").ToString()) And CLng(strID)
End If
End Sub
I'm so confused.. ha.