Home All Groups Group Topic Archive Search About
Author
4 May 2006 5:07 PM
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.

Author
4 May 2006 5:22 PM
yoga weazel
Q1.  If I follow you correctly I would recommend using LoadControl in the
PreRender event.

Q2. The only thing I can think of off hand is registering the child controls
in the parent.  This won't be a problem if you have a pre-defined list of
child control types.



Show quoteHide quote
"Giovanni" wrote:

> 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.
Author
4 May 2006 5:35 PM
Giovanni
Can you please help me with #2?  Any example Vb.NEt code?

Show quoteHide quote
"yoga weazel" wrote:

> Q1.  If I follow you correctly I would recommend using LoadControl in the
> PreRender event.
>
> Q2. The only thing I can think of off hand is registering the child controls
> in the parent.  This won't be a problem if you have a pre-defined list of
> child control types.
>
>
>
> "Giovanni" wrote:
>
> > 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.