Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Chris Kennedy #1
Dynamically adding controls to a data repeater
I would like to create a composite control based on a data repeater how do I
dynamically add and bind child controls to it? I imagine this is not a one
post answer so any pointers to books or resources to developing such a
control in vb.net would be great. Regards, Chris.
Chris Kennedy Guest
-
Adding controls dynamically to a datagrid
Hi, We have a requirement, where based on the UI type selected in a dropdown, a control should get added to the column of a grid dynamically. For... -
Dynamically Adding Controls
I am trying to dynamically add controls to my page, but am having trouble with controls such as buttons. I have been able to add simple controls... -
dynamically adding user controls
I have a web form that has a button called "Add Blank Row". Every time this button is pressed a new "blank row" user control should be added to the... -
Dynamically adding different controls to different rows in DataGrid does not work
Hi! I've got a datagrid which I dynamically want to add controls to, and the type of control depends on user rights for the item shown in the... -
ANNOUNCEMENT : Samples for Datagrid, Datalist, Data Repeater controls
hi all, Check this link for updated scrollable grid sample and download gridtest.zip from my site for the source.... -
John Saunders #2
Re: Dynamically adding controls to a data repeater
"Chris Kennedy" <chrisknospam@cybase.co.uk> wrote in message
news:OqFlzNvSEHA.808@tk2msftngp13.phx.gbl...I> I would like to create a composite control based on a data repeater how doThe basic idea is to do programatically what you would have done in the> dynamically add and bind child controls to it? I imagine this is not a one
> post answer so any pointers to books or resources to developing such a
> control in vb.net would be great. Regards, Chris.
..aspx file. So, for instance:
<asp:Repeater runat="server" id="myRepeater" ...>
<ItemTemplate>
<asp:Label runat="server" id="myLabel" Text="Label Text" />
</ItemTemplate>
</asp:Repeater>
Programatically:
Repeater myRepeater = new Repeater();
myRepeater.Id = "myRepeater";
myRepeater.ItemTemplate = new MyItemTemplate();
---
private class MyItemTemplate : ITemplate
{
void ITemplate.InstantiateIn(Control container) {
Label myLabel = new Label();
myLabel.Id = "myLabel";
myLabel.Text = "Label Text";
container.Controls.Add(myLabel);
}
}
If the repeater is the only control in your composite, then your new control
can simply derive from Repeater. If you need more than one, your new control
should go ahead and create a composite control.
Here are some references:
Developing ASP.NET Server Controls
([url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht[/url]
ml/cpconkeyconceptsinwebformscontroldevelopment.asp)
Control Execution Lifecycle
([url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht[/url]
ml/cpconcontrolexecutionlifecycle.asp?frame=true)
ASP.NET Server Control Development Basics
([url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht[/url]
ml/cpconwebformscontroldevelopmentbasics.asp)
Developing a Composite Control
([url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht[/url]
ml/cpcondevelopingcompositecontrols.asp)
Design-Time Support for Web Forms
([url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht[/url]
ml/cpcondesign-timeforwebforms.asp)
--
John Saunders
johnwsaundersiii at hotmail
John Saunders Guest



Reply With Quote

