using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
namespace 乘法口诀
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//第一种方法
StringBuilder sb = new StringBuilder();
sb.Append("<table>");
for (int i = 1; i < 10; i++)
{
sb.Append("<tr>");
for (int j = 1; j <= i; j++)
{
sb.Append("<td>" + i + "*" + j + "=" + i * j + "</td>");
}
sb.Append("</tr>");
}
sb.Append("</table>");
this.div.InnerHtml = sb.ToString();
//第二种方法
HtmlTable table = new HtmlTable();
for (int i = 1; i < 10; i++)
{
HtmlTableRow tr = new HtmlTableRow();
for (int j = 1; j <=i; j++)
{
HtmlTableCell td = new HtmlTableCell();
td.InnerText = i + "*" + j + "=" + i * j;
tr.Controls.Add(td);
}
table.Controls.Add(tr);
}
this.div1.Controls.Add(table);
}
}
}
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
namespace 乘法口诀
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//第一种方法
StringBuilder sb = new StringBuilder();
sb.Append("<table>");
for (int i = 1; i < 10; i++)
{
sb.Append("<tr>");
for (int j = 1; j <= i; j++)
{
sb.Append("<td>" + i + "*" + j + "=" + i * j + "</td>");
}
sb.Append("</tr>");
}
sb.Append("</table>");
this.div.InnerHtml = sb.ToString();
//第二种方法
HtmlTable table = new HtmlTable();
for (int i = 1; i < 10; i++)
{
HtmlTableRow tr = new HtmlTableRow();
for (int j = 1; j <=i; j++)
{
HtmlTableCell td = new HtmlTableCell();
td.InnerText = i + "*" + j + "=" + i * j;
tr.Controls.Add(td);
}
table.Controls.Add(tr);
}
this.div1.Controls.Add(table);
}
}
}