|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can a Repeater control repeat an .ascx?hi, its pretty simple and i dont think there is any articles online to
showcase this. I am pasting a simple test with 1 user control( that contains a single textbox, whose text property is populated from the repeaters databound datasource). The user control is contained within the repeaters ItemTemplate. Also look up this reference on msdn since the example code might help you : http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.itemtemplate.aspx Regards, Alessandro Zifiglio http://www.AsyncUI.net in your parent page .aspx : ---------------------------- <%@ Register Src="WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Repeater ID="Repeater1" runat="server"> <HeaderTemplate> <ul> </HeaderTemplate> <ItemTemplate> <li> <uc1:WebUserControl Text='<%# Container.DataItem %>' ID="WebUserControl1" runat="server" /> </li> </ItemTemplate> <FooterTemplate> </ul> </FooterTemplate> </asp:Repeater> </div> </form> </body> </html> your parent page code-behind : -------------------------------- protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ArrayList values = new ArrayList(); values.Add("Apple"); values.Add("Orange"); values.Add("Pear"); values.Add("Banana"); values.Add("Grape"); Repeater1.DataSource = values; Repeater1.DataBind(); } } WebUserControl .ascx : -------------------------- <span>Fruit is :</span> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> WebUserControl .cs code behind : -------------------------- protected void Page_Load(object sender, EventArgs e) { // code for page load here } public string Text { get { return TextBox1.Text; } set { TextBox1.Text = value; } } Show quoteHide quote "TJ" <teejay@newsgroups.nospam> ha scritto nel messaggio news:e33sZQ0qGHA.4408@TK2MSFTNGP04.phx.gbl... > Any help or tutorial link would be greatly appreciated. > Thx > > Yes it can. Alessandro pointed out an example, I have a one blog post where
user control is used as a loadable template (not inside <ItemTemplate>) but it proves the same point http://aspadvice.com/blogs/joteke/archive/2006/07/06/19348.aspx Show quoteHide quote "TJ" <teejay@newsgroups.nospam> wrote in message news:e33sZQ0qGHA.4408@TK2MSFTNGP04.phx.gbl... > Any help or tutorial link would be greatly appreciated. > Thx > > Many thanks to you both, this is exactly what I was looking for.
Show quoteHide quote "TJ" <teejay@newsgroups.nospam> wrote in message news:e33sZQ0qGHA.4408@TK2MSFTNGP04.phx.gbl... > Any help or tutorial link would be greatly appreciated. > Thx > > Your welcome TJ. Nice article Teemu, you did a fine job. Thanks for sharing
:-) Regards,Alessandro Zifiglio http://www.AsyncUI.net Show quoteHide quote "TJ" <teejay@newsgroups.nospam> ha scritto nel messaggio news:u69J0n2qGHA.4684@TK2MSFTNGP05.phx.gbl... > Many thanks to you both, this is exactly what I was looking for. > > "TJ" <teejay@newsgroups.nospam> wrote in message > news:e33sZQ0qGHA.4408@TK2MSFTNGP04.phx.gbl... >> Any help or tutorial link would be greatly appreciated. >> Thx >> >> > >
DropdownList problem with internet explorer
Firing events for child controls inside a DataGrid passing data on the cleint side CustomValidator How-to link 2 Detailsview Formview child control data retrieval ASP.NET vs Windows Forms for building client application Windows control in .ASPX page .Net 2.0 - WebBrowser control embedded in IE causes problems Commenting Out Controls In HTML View |
|||||||||||||||||||||||