Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

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)

Posted
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

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)

Posted
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

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)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...