Dynamically placing controls/ page items at runtime

T

The Crow

placing runat="server" to the table and and something like ,
table.Rows[4].Cells[3].Controls.Add(lnkButton); , will work.
 
C

chris

Grant said:
I have this table on my form which gets populated with data from my
database at runtime. I would like to place some controls (linkbutton,
textbox etc.) beneath the table when it is complete - at the moment the
controls just stay where I place them and the table gets built on top of
them. I have tried searching the net for a solution but being on dial up
its excruciatingly slow and I havent yet found the answer. Please could
someone point me in the right direction...

I am using c# and asp.net

Thanks,
Grant
 
G

Grant

I have this table on my form which gets populated with data from my database
at runtime. I would like to place some controls (linkbutton, textbox etc.)
beneath the table when it is complete - at the moment the controls just stay
where I place them and the table gets built on top of them. I have tried
searching the net for a solution but being on dial up its excruciatingly
slow and I havent yet found the answer. Please could someone point me in the
right direction...

I am using c# and asp.net

Thanks,
Grant
 
O

Ollie Riches

All web controls inherit from System.Web.UI.Control which has a property
called 'Controls' this is container of controls hosted by the current
control so you can do the following if you had a Panel control on your aspx
page:

....
TextBox myTextBox = new TextBox();
myPanel.Controls.Add(myTextBox);
....

Or since you are displaying information from a database I guess you are
using a DataGrid or Repeater control both of which support header and footer
templates that allow you to add controls as you wish

here is an article on adding controls to the footer of a datagrid

http://www.extremeexperts.com/Net/Articles/AddingControlstoFooter.aspx

datagrid girl is always a good resource as well:

http://www.datagridgirl.com/default.aspx

HTH

Ollie Riches
 
J

J. Merrill

Did "chris" actually say nothing, or is it just not visible via the MS
web-based newsreader?

Thanks.
 
G

Grant

Thanks this worked for me :)

Ollie Riches said:
All web controls inherit from System.Web.UI.Control which has a property
called 'Controls' this is container of controls hosted by the current
control so you can do the following if you had a Panel control on your
aspx page:

...
TextBox myTextBox = new TextBox();
myPanel.Controls.Add(myTextBox);
...

Or since you are displaying information from a database I guess you are
using a DataGrid or Repeater control both of which support header and
footer templates that allow you to add controls as you wish

here is an article on adding controls to the footer of a datagrid

http://www.extremeexperts.com/Net/Articles/AddingControlstoFooter.aspx

datagrid girl is always a good resource as well:

http://www.datagridgirl.com/default.aspx

HTH

Ollie Riches
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top