G
Giovanni
I have been stumped by this problem for the past 2 days:
Assuming I have a GridView contained within a UserControl. The grid
contains 3 columns (Column 1: QuestionNumber, Column 2: QuestionText, and
Column 3: TemplateField). In the third column (the TemplateField), I have a
dragged-and-dropped a UserControl (QuestionTypeUserControl). The
QuestionTypeUserControl has an Integer property: QuestionTypeID, and itself
is empty (contains no controls). On the GridView's RowDataBound event, I
pass a DataKey value to QuestionTypeUserControl.QuestionTypeID. This is
where the problem is:
I have built several other UserControls which resemble server controls,
but have additional functionality (Ex.: DropDownListExUserControl,
TextBoxExUserControl have an additional label, etc...). Depending on the
value of QuestionTypeID, the QuestionType UserControl (thusfar empty), would
decide which child UserControl(s) to add to itself. In essence, the Parent
(QuestionTypeUserControl), determines which children it will add to itself,
based on a value (QuestionTypeID).
1. What is the best approach to accomplish this. Must I use the
..LoadControl in the parent (QuestionTypeUserControl)? and which event is best
to do this?
2. What considerations must I take to compensate for ASP.NET 2.0's
dynamic compilation model, both in the parent and child UserControls.
I guess in the end, it is a 3 layer-nested UserControl (GridView
contains a UserControl type TemplateField, which itself contains any number
of UserControls).
Thank you for all your help and ideas.
Regards,
Giovanni P.
Assuming I have a GridView contained within a UserControl. The grid
contains 3 columns (Column 1: QuestionNumber, Column 2: QuestionText, and
Column 3: TemplateField). In the third column (the TemplateField), I have a
dragged-and-dropped a UserControl (QuestionTypeUserControl). The
QuestionTypeUserControl has an Integer property: QuestionTypeID, and itself
is empty (contains no controls). On the GridView's RowDataBound event, I
pass a DataKey value to QuestionTypeUserControl.QuestionTypeID. This is
where the problem is:
I have built several other UserControls which resemble server controls,
but have additional functionality (Ex.: DropDownListExUserControl,
TextBoxExUserControl have an additional label, etc...). Depending on the
value of QuestionTypeID, the QuestionType UserControl (thusfar empty), would
decide which child UserControl(s) to add to itself. In essence, the Parent
(QuestionTypeUserControl), determines which children it will add to itself,
based on a value (QuestionTypeID).
1. What is the best approach to accomplish this. Must I use the
..LoadControl in the parent (QuestionTypeUserControl)? and which event is best
to do this?
2. What considerations must I take to compensate for ASP.NET 2.0's
dynamic compilation model, both in the parent and child UserControls.
I guess in the end, it is a 3 layer-nested UserControl (GridView
contains a UserControl type TemplateField, which itself contains any number
of UserControls).
Thank you for all your help and ideas.
Regards,
Giovanni P.