开发者

Recursively extract dynamically created controls in a repeater, Part II [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. 开发者_JAVA百科 Closed 10 years ago.

To be fair, this is a part two follow up to Using C# to recursively get a collection of controls from a controlcollection - and rather than heap another question onto the old one, I created a new one. Here is the code that I'm using:

private void GetControlList<T>(ControlCollection controlCollection, ref List<T> resultCollection) where T : Control 
{
    foreach (Control control in controlCollection)
    {
        if (control.HasControls())
            GetControlList(control.Controls, ref resultCollection);
        else if (control is T)
            resultCollection.Add((T)control);
    }
}

and is involked like this when the form is submitted

List<CheckBox> checkboxes = new List<CheckBox>();
GetControlList(RepeaterCapability.Controls, ref checkboxes);

The problem is that I don't get any results when I clearly added several during the repeater OnItemDataBound event. Any ideas?


Have you checked the Repeater.Items property?


REsolved ... PEBKAC

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜