0

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

2 Answers 2

2
//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>");
            }
      }

Source: http://forums.asp.net/t/1955897.aspx

Sign up to request clarification or add additional context in comments.

Comments

2

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);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.