for example, i have text box and i have entered "for example".
now, i want to create a new <table> and a <tr> to that table, and a <td> for each ward entered.
how can i do that?Thanks for the help
//figure out the number of table row and column.
int rowNum = 5;
int colNum = 2;
System.Text.StringBuilder sb=new System.Text.StringBuilder();
if(attachmentName.Count > 0){
sb.Append("<Table>");
for (int i = 0; i < rowNum; i++) {
sb.Append("<tr>");
for (int j = 0; j < colNum; j++)
{
sb.Append("<td>");
//add your a tab and img tag....
// by attachmentName[i][j]
sb.Append("");
sb.Append("</td>");
}
sb.Append("</tr>");
}
}
You should use HTMLGeneric class for that.
Suppose that you want to add a tr you can create it as follows
HtmlGenericControl tr = new HtmlGenericControl("tr");
You can add td in tr as follows
HtmlGenericControl td = new HtmlGenericControl("td");
tr.Controls.Add(td);
Similarly you can create any html controls
and finally add it in your parent control which is on the page. Suppose it is a panel with id pannel1 then
pannel1.Controls.Add(panle1);