【问题标题】:Recursively extract dynamically created controls in a repeater, Part II [closed]在转发器中递归提取动态创建的控件,第二部分 [关闭]
【发布时间】:2010-12-16 17:19:37
【问题描述】:

说句公道话,这是Using C# to recursively get a collection of controls from a controlcollection 的第二部分 - 我没有在旧问题上堆砌另一个问题,而是创建了一个新问题。这是我正在使用的代码:

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);
    }
}

并在提交表单时这样调用

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

问题是,当我在转发器 OnItemDataBound 事件期间明确添加了几个时,我没有得到任何结果。有什么想法吗?

【问题讨论】:

    标签: c# asp.net repeater


    【解决方案1】:

    您检查过Repeater.Items 属性吗?

    【讨论】:

      【解决方案2】:

      已解决...PEBKAC

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-04-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多