mike55 Posted March 30, 2005 Posted March 30, 2005 Hi, Have created a user control, with two grids. Each grid has a column of checkbuttons that the user can select, I also have declared two arrays: arrayGroups and arrayMembers, as strings (size = 1). Now when I click the first button on the form the following method should run Public Function retrieveSelected(ByVal dgName As DataGrid, ByVal arrayName As String) Dim rsc As MetaBuilders.WebControls.RowSelectorColumn = MetaBuilders.WebControls.RowSelectorColumn.FindColumn(dgName) Dim selected As Integer Dim selIndex As Integer Dim person As TableCell selected = 0 For Each selIndex In rsc.SelectedIndexes selected = selected + 1 Next If arrayName = "arrayMembers" Then ReDim arrayMembers(selected) ElseIf arrayName = "arrayGroups" Then ReDim arrayGroups(selected) End If 'Dim arraySelected(selected) As String Dim position As Integer position = 0 For Each selIndex In rsc.SelectedIndexes person = dgMembers.Items(selIndex).Cells(1) If arrayName = "arrayMembers" Then arrayMembers(position) = person.Text ElseIf arrayName = "arrayGroups" Then arrayGroups(position) = person.Text End If 'arraySelected(position) = person.Text position = position + 1 Next End Function The problem is that the arrays arrayGroup, and arrayMembers, loses all the data assigned to it when the method is finished executing, any suggestions on how to maintain the data long term. Mike55 Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Administrators PlausiblyDamp Posted March 30, 2005 Administrators Posted March 30, 2005 ReDim Preserve arrayGroups(selected) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mike55 Posted March 30, 2005 Author Posted March 30, 2005 ReDim Preserve arrayGroups(selected) No, The Preserve keyword doesn't work, when the method terminates the array looses all its data and returns to it original size. Have declared the array at the top of my user control as follows: Private arrayMembers(1) As String Private arrayGroups(1) As String Any other suggestions?? Mike55 Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Administrators PlausiblyDamp Posted March 30, 2005 Administrators Posted March 30, 2005 You will need to implement some form of state management within your application, the variables are being recreated and destroyed on every page refresh. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mike55 Posted March 30, 2005 Author Posted March 30, 2005 You will need to implement some form of state management within your application' date=' the variables are being recreated and destroyed on every page refresh.[/quote'] Yea, I see what you mean, this is the first time I ever came across this problem. Am in the process of looking for a simple solution. Mike55 Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.