简体   繁体   中英

Dynamically load user control

I have this GridView that have it's DataSource as a list of previously selected products. 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.

I have made those specific forms as User Controls , is this the best approach for this scenario?

If yes, how can I dynamically load them, in a way that I can make queries/postbacks then update back my 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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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