简体   繁体   English

动态加载用户控制

[英]Dynamically load user control

I have this GridView that have it's DataSource as a list of previously selected products. 我有这个GridView ,它的DataSource是以前选择的产品的列表。 For every item on it, I need to Eval it's ID and load a specifc form that the user must fill, then after that i've got to update the GridView. 对于其中的每个项目,我都需要评估其ID并加载用户必须填写的特定表格,然后在此之后我必须更新GridView。

I have made those specific forms as User Controls , is this the best approach for this scenario? 我已经将这些特定的表格作为“ User Controls ,这是此方案的最佳方法吗?

If yes, how can I dynamically load them, in a way that I can make queries/postbacks then update back my gridview? 如果是,如何动态地加载它们,以使我可以进行查询/回发,然后更新回自己的gridview?

What you want to develop is called Master/Detail view. 您要开发的东西称为“主视图/详细视图”。 It is described for example in http://www.asp.net/data-access/tutorials/master-detail-using-a-selectable-master-gridview-with-a-details-detailview-cs . 例如在http://www.asp.net/data-access/tutorials/master-detail-using-a-selectable-master-gridview-with-a-details-detailview-cs中进行了描述。

The only difference that as Detail you need use FormView, where on some initialization event (like DataBound http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.basedataboundcontrol.databound.aspx )you need to dynamically create you control and set its parent to current template of FormView 作为Detail,您需要的唯一区别是使用FormView,在某些初始化事件(例如DataBound http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.basedataboundcontrol.databound.aspx )上,您需要动态创建控件并将其父级设置为FormView的当前模板

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM