Howdy,
Yes it is, two ways:
1. through data binding:
<asp:Repeater runat="server" ID="dynamicControls">
<ItemTemplate>
<uc1:MyUserControl runat="server" ID="userControl" CustomDateProperty='<%#
DateTime.Now %>'/>
</ItemTemplate>
</asp:Repeater>
2. or in the code behind:
<asp:Repeater runat="server" ID="dynamicControls"
OnItemDataBound="dynamicControls_ItemDataBound">
<ItemTemplate>
<uc1:MyUserControl runat="server" ID="userControl" />
</ItemTemplate>
</asp:Repeater>
-- c# code behind --
protected void dynamicControls_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if (item.ItemType == ListItemType.Item ||
item.ItemType == ListItemType.AlternatingItem)
{
MyUserControl ctrl = (MyUserControlClassName)
item.FindControl("userControl");
ctrl.CustomDateProperty = DateTime.Now;
}
}
HTH
--
Milosz
[quoted text, click to view] "param@community.nospam" wrote:
> OK,
>
> Thanks for the tip. Now, what if I need to set custom properties on my
> usercontrol. Is that possible?
>
> TIA!
>
> "Milosz Skalecki [MCAD]" <mily242@DONTLIKESPAMwp.pl> wrote in message
> news:B89DDECD-A644-4935-AC3C-1501108EB518@microsoft.com...
> > Howdy,
> >
> > Use Repeater or DataList:
> >
> > -- aspx code --
> > <asp:Repeater runat="server" ID="dynamicControls">
> > <ItemTemplate>
> > <uc1:myUserControl runat="server" ID="myUserControl"/>
> > </ItemTemplate>
> > </asp:Repeater>
> > -- c# code beside --
> > protected void Page_Load(object sender, EventArgs e)
> > {
> > if (!IsPostBack)
> > {
> > int rowCount = 10;
> > myRepeater.DataSource = new int[rowCount];
> > myRepeater.DataBind();
> > }
> > }
> >
> > Hope it helps
> > --
> > Milosz
> >
> >
> > "param@community.nospam" wrote:
> >
> >> Hello all,
> >>
> >> I have a UserControl that renders some HTML content. I now need to
> >> dynamically load and render "n" instances of this usercontrol on a host
> >> aspx
> >> page inside a panel control based upon user input of "n". Any ideas how I
> >> can do this?
> >>
> >> TIA!
> >>
> >>
> >>
>
>