Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to add any rows to table(<asp:table>) in runtime with asp.net?
Posted
Updated 14-Jun-14 17:09pm
v2
Comments
[no name] 14-Jun-14 23:06pm    
A little bit of research goes a long way to answering your own questions, http://msdn.microsoft.com/en-us/library/5ycd1034.aspx
[no name] 14-Jun-14 23:12pm    
Oh! A web table. Why didn't you say so to begin with? Still a little bit of research.... http://msdn.microsoft.com/en-us/library/vstudio/7bewx260(v=vs.100).aspx
Please add this as answer. :)

Hello friend, try this code:

Page.aspx
ASP.NET
<asp:table id="Table1" runat="server" borderstyle="Solid" borderwidth="1" width="100px" xmlns:asp="#unknown"></asp:table>

Page.aspx.cs
C#
//Create a Label control to show a message
Label lbl = new Label();
lbl.Text="Hello world";

//Create a TableRow control
TableRow tr = new TableRow();

//Create a TableCell control
TableCell tc = new TableCell();

//Add the lable to TableCell control
tc.Controls.Add(lbl);

//Add TableCell control to TableRow control
tr.Cells.Add(tc);

//Finally add the TableRow to Table control
Table1.Rows.Add(tr);

Let me know in case of any further query.

- DD
 
Share this answer
 
Comments
Nirav Prabtani 16-Jun-14 1:20am    
my 4+
Debabrata_Das 16-Jun-14 1:23am    
Thanks Nirav :)
Srinivas Kumar Pasumarthi 16-Jun-14 8:48am    
http://aspdotnetfiddle.com/S14UR

check the above link for online implementation
Read solution 1 and then see this reference for more information. :)

Dynamically adding rows to the table (C#)[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900