473,499 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Tables dynamically??

Hello,

How can I add a table to asp.net page dynamically with Code Behind
style.

I still can't find a way of doing it. This really causes me a big
problem when I deal with records from database as I need to construct
the table dynamically.
MTIA,
Grawsha

Nov 19 '05 #1
2 1627
gr*********@yahoo.com wrote in news:1113619342.585822.187010
@l41g2000cwc.googlegroups.com:
Hello,

How can I add a table to asp.net page dynamically with Code Behind
style.

I still can't find a way of doing it. This really causes me a big
problem when I deal with records from database as I need to construct
the table dynamically.

1. Take a look at a datagrid... it's great for grid like data. No point
in rewriting a grid...

2. If you want to use a table, place a table onto the webpage (or a
placeholder).

Then do the following:

dim cell as tablecell
dim row as tablerow
For Loop Here
cell = new tablecell
row = new tablecell
row.cells.add(cell)
table.rows.add(row)
Next
That's how you add a row.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 19 '05 #2
There are a few options which you can take:

1. Look into using the Repeater or DataGrid controls to display your
records

2. You can add an <asp:Label...> control to your form, then in the
code-behind, generate your table structure through a
"<table><tr><td>...</td></tr></table>" string and assign that string to the
Label1.Text property.

3. Dynamically create an ASP.NET table and add it to the Control collection
of a Placeholder object. (code shown below)
- In the ASPX form, create an <asp:Placeholder object (name "plc") where
you would like the table to go
- In the code-behind, dynamically generate the table and add the table
to PlaceHolder.Controls
Dim tbl As New System.Web.UI.WebControls.Table

Dim row As System.Web.UI.WebControls.TableRow

Dim cell As System.Web.UI.WebControls.TableCell

row = New System.Web.UI.WebControls.TableRow

tbl.Rows.Add(row)

cell = New System.Web.UI.WebControls.TableCell

cell.Text = "Test"

row.Cells.Add(cell)

plc.Controls.Add(tbl)
HTH,
Jody
<gr*********@yahoo.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
Hello,

How can I add a table to asp.net page dynamically with Code Behind
style.

I still can't find a way of doing it. This really causes me a big
problem when I deal with records from database as I need to construct
the table dynamically.
MTIA,
Grawsha

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6091
by: Grant Gardiner | last post by:
This is an interesting one... You have a Word document with a parent table. Inside this is another table. This subtable has 4 columns, where I need to dynamically insert FormFields into each...
11
2264
by: Steven D'Aprano | last post by:
Suppose I create a class with some methods: py> class C: .... def spam(self, x): .... print "spam " * x .... def ham(self, x): .... print "ham * %s" % x .......
0
1271
by: Dude | last post by:
I am using new_range.InsertAfter txt new_range.ConvertToTable vbTab new_range.InsertBreak new_range.InsertAfter txt2 new_range.ConvertToTable vbTab new_range.InsertBreak
4
5447
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
3
4855
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
0
1860
by: Sileesh | last post by:
Hi I have html table and a Button in an Aspx page. I am adding one row with some textboxes to Html table each time i click on the Button thru Javascript. Now problem is when when i try to...
1
1639
by: C Downey | last post by:
I have a registration form that should load different web user controls based on the selection of a dropdown list. Basically, the user follows the following steps: 1. user comes to very basic...
2
1342
by: Nathan Sokalski | last post by:
I have a page on which I want to display several sections each of which contain a list of names. I have two database tables, one of which contains the section headings, and the other contains the...
2
1688
by: kalaivanan | last post by:
hi, i am trying to add a datagrid control to a web page dynamically. i am able to do it while i used the following code in the page load event of the form in which i am going to add the control. ...
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7225
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5479
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3105
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.