Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 09, 2012 08:43 AM by ramiramilu
Member
8 Points
79 Posts
May 07, 2012 05:27 AM|LINK
Hi,
Can any one tell me how to generate dynamically table row and list item in asp.net 4.0
for example
A-table row
a1-list item
a2
B-Table row
b1-list item
b2
pls can anyone help me to code
All-Star
16006 Points
1728 Posts
Microsoft
May 09, 2012 08:10 AM|LINK
Try this:
private void CreateDynamicTable() { PlaceHolder1.Controls.Clear(); int tblRows = 2; int tblCols = 3; Table tbl = new Table(); tbl.CellSpacing = 3; tbl.CellPadding = 2; tbl.BorderWidth=1; tbl.BorderColor = System.Drawing.Color.Blue; PlaceHolder1.Controls.Add(tbl); for (int i = 0; i < tblRows; i++) { TableRow tr = new TableRow(); for (int j = 0; j < tblCols; j++) { TableCell tc = new TableCell(); tc.Text = "a1-list item" + "<br/>" + "a2"; tr.Cells.Add(tc); } tbl.Rows.Add(tr); } }
95363 Points
14096 Posts
May 09, 2012 08:43 AM|LINK
I would say Nested Repeater may be one more option you can think of...it makes much more easy....than dyanamically generating tables rows - http://www.mikesdotnetting.com/Article/57/Displaying-One-To-Many-Relationships-with-Nested-Repeaters
http://www.codeproject.com/Articles/10291/Nesting-Repeaters-with-Hierarchical-Data-and-Serve
Thanks,
nikitha
Member
8 Points
79 Posts
Dymaically generate table row and list view in asp.net 4.0
May 07, 2012 05:27 AM|LINK
Hi,
Can any one tell me how to generate dynamically table row and list item in asp.net 4.0
for example
A-table row
a1-list item
a2
B-Table row
b1-list item
b2
pls can anyone help me to code
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: Dymaically generate table row and list view in asp.net 4.0
May 09, 2012 08:10 AM|LINK
Try this:
private void CreateDynamicTable() { PlaceHolder1.Controls.Clear(); int tblRows = 2; int tblCols = 3; Table tbl = new Table(); tbl.CellSpacing = 3; tbl.CellPadding = 2; tbl.BorderWidth=1; tbl.BorderColor = System.Drawing.Color.Blue; PlaceHolder1.Controls.Add(tbl); for (int i = 0; i < tblRows; i++) { TableRow tr = new TableRow(); for (int j = 0; j < tblCols; j++) { TableCell tc = new TableCell(); tc.Text = "a1-list item" + "<br/>" + "a2"; tr.Cells.Add(tc); } tbl.Rows.Add(tr); } }Feedback to us
Develop and promote your apps in Windows Store
ramiramilu
All-Star
95363 Points
14096 Posts
Re: Dymaically generate table row and list view in asp.net 4.0
May 09, 2012 08:43 AM|LINK
I would say Nested Repeater may be one more option you can think of...it makes much more easy....than dyanamically generating tables rows - http://www.mikesdotnetting.com/Article/57/Displaying-One-To-Many-Relationships-with-Nested-Repeaters
http://www.codeproject.com/Articles/10291/Nesting-Repeaters-with-Hierarchical-Data-and-Serve
Thanks,
JumpStart