Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Collection behavior when adding a new item
Message
From
25/07/2006 13:34:02
 
 
To
25/07/2006 11:52:45
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01138855
Message ID:
01139828
Views:
11
>>No. Since your collection is storing a reference to the object array you'd need to create a new one for each item in the collection - basically what you're Redim is doing now. I'd do something like this instead (sorry, C#):
>>
>>
>>System.Collections.ArrayList ODropDownCondition = new System.Collections.ArrayList();
>>
>>ODropDownCondition.Add(new string[2] {"No DBUsers","Something"});
>>ODropDownCondition.Add(new string[2] {"No DBUsers2","Something"});
>>
>>foreach (string[] s in ODropDownCondition)
>>    {
>>        oApp.AddJavascriptMessage(s[0]);
>>    }
>>
>
>Ok, I see why I never had this problem before. In similar locations where I am using this technique to add something in a collection, I am doing something like this:
>
>
>        ' Add the information for an extra option for a record
>        ' expC1 Image
>        ' expC2 Tooltip
>        ' expC3 Javascript function
>        '       Optional
>        ' expC4 Url
>        '       Optional
>        ' expC5 Url parameter
>        '       Optional
>        Public Function AddExtraOptionRecord(ByVal tcImage As String, ByVal tcTooltip As String, _
>         Optional ByVal tcJavascriptFunction As String = "", _
>         Optional ByVal tcUrl As String = "", _
>         Optional ByVal tcUrlParameter As String = "") As Boolean
>            Dim loExtraOptionRecord(5) As Object
>            loExtraOptionRecord(1) = tcImage
>            loExtraOptionRecord(2) = tcTooltip
>            loExtraOptionRecord(3) = tcJavascriptFunction
>            loExtraOptionRecord(4) = tcUrl
>            loExtraOptionRecord(5) = tcUrlParameter
>            oExtraOptionRecord.Add(loExtraOptionRecord)
>            Return True
>        End Function
>
>
>So, everytime I have a need to add an item in that collection, I am calling this method. As everytime I call the method, loExtraOptionRecord() is initialized, I am not facing that situation here.
>
>I will do the same for oDropDownCondition. I will add a method in the required class and proceed by doing a call to the method whenever I have a need to add a condition. Basically, this was the best setup for me. I just don't understand why I did the oDropDownCondition with the approach that caused me some problem. :) By calling a method, the intellisense kicks in to show me what to pass as a parameter so it is also much easier to handle.

Should work fine - but the end result is still basically identical to using a Redim to create a new object...
Regards,
Viv
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform