Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wanted to Dynamically Add Row to HTML Table which had already 3,3 rows ,cols on Button Click.and how to retrive the values from the dynamically created textboxes....
Posted
Comments
Menelaos Vergis 4-Oct-12 6:41am    
You have to ether use AJAX Panel of ASP and postback with the new row created at the datasource or you have to relay only on client side code

XML
<pre lang="c#">
Tr=new HtmltableRow();
Tc=New HtmlTableCell();
//content of Tc
Tr.cells.Add(Tc);
TblView.Rows.Add(Tr);
</pre>
 
Share this answer
 
What is the problem then. Use loop to create Rows & Columns to the table and add those rows to the Table.
Try something like this:
C#
//Creating a new table object
Table tbl = new Table();
tbl.Width = Unit.Percentage(100);
TableRow tblRow = new TableRow();
int cellInd = 0;
for (int i = 0; i < 3; i++)
{    
    //Creating a new row index
    tblRow = new TableRow();
    for (int j = 0; j < 3; j++)
    {
        //Creating a new column for the above row index
        TableCell tblCell = new TableCell();
        tblCell.Width = Unit.Percentage(25);
        tblRow.Controls.Add(tblCell);
    }
    tbl.Rows.Add(tblRow);
}



Hope it helps.
--Amit
 
Share this answer
 
Comments
srinath.pothineni 5-Oct-12 7:56am    
how to get the details from the dynamically created text boxes and i want to store those values into the database..
_Amy 5-Oct-12 8:09am    
use FindControl with respective ID to find the Dynamically created textboxes.

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