如何从多个用户控件(.ascx)中获取数据 [英] How to get data from more than one user control (.ascx)

查看:143
本文介绍了如何从多个用户控件(.ascx)中获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对所有人都好:)
我正在使用以下代码.
在我的页面上,有" count "个用户控件,这些控件在运行时生成.

Hay to all, :)
i am using following code.
On my page ,there are "count" number of user controls ,which are generating at run time.

for (int i = 0; i < count; i++)
                {

Control MyCustomControl = LoadControl("DynamicData/FieldTemplates/ColumnDetails.ascx");
Controls.Add(MyCustomControl);   PlaceHolderUserControl.Controls.Add(MyCustomControl);
     
                }


现在,我想从所有这些用户控件中获取数据.


Now I want to get data from all of these user controls.

推荐答案

您可能想要保留要添加到控件集合的控件的ClientId列表. .您甚至可以使用简单的字符串列表来实现此目的.当您需要它们的信息时,可以执行Controls.FindControl(< savedclientid>)来检索它们,然后处理您想要的任何内容.
You may want to keep a list of the ClientIds of the controls you are adding to your Controls Collection. You can even use something as simple as a List of strings to achieve this. When you want information from them, you can do a Controls.FindControl( <savedclientid> ) to retrieve them and then process whatever you want from them.


这篇关于如何从多个用户控件(.ascx)中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆