_menus.Count is 2 before the loop. And the second, foreach loop adds 2
Labels and 2 HoverMenuExtenders as it should. I tried the first loop with a
foreach initially, but remembering SyncRoot issues and thought perhaps the
enumerator was breaking the Add operation, I changed it to the for loop to
no avail.
"IfThenElse" <> wrote in message
news:%...
> What is the value of _menus.Count before the for loop
>
>
> "Chad Scharf" <> wrote in message
> news:%...
>> Ok, as silly as it may sound, I have a situation where I am creating a
>> CompositeControl in ASP.NET 2.0, C#. I have the following code in the
>> CreateChildControls() method that build the control's child control
>> collection:
>>
>> for (int i = 0; i < _menus.Count; i++)
>> this.Controls.Add(_menus[i]);
>>
>> foreach (FloatingMenu menu in _menus)
>> {
>> Label lbl = new Label();
>> lbl.ID = string.Concat("GroupQ", menu.ID);
>> lbl.CssClass = "menuItemGroupHeader";
>> lbl.Text = menu.GroupName;
>> this.Controls.Add(lbl);
>>
>> HoverMenuExtender extender = new HoverMenuExtender();
>> extender.ID = string.Concat("ExtenderQ", menu.ID);
>> extender.TargetControlID = lbl.ID;
>> extender.PopupControlID = menu.ID;
>> extender.PopupPosition = HoverMenuPopupPosition.Bottom;
>> this.Controls.Add(extender);
>> }
>>
>>
>> The amazing thing is here, that the Label control and the
>> HoverMenuExtender AJAX Toolkit control both get added just fine, however
>> I added a watch on this.Controls.Count for the line where I add my
>> FloatingMenu control collection, "_menus", and after each call to
>> "this.Controls.Add(_menus[i]);" the Count is 0, however after I add the
>> label it's 1 and the extender it's 2.
>>
>> I'm stumped.
>>
>> Thanks,
>> Chad
>>
>
>
|