看看这个n*n乘法表输出问什么不能输出
[code=C#][/code]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;
public partial class _2 : System.Web.UI.Page
{
protected void mul(int x)
{
int i, j;
TableRow tr;
TableCell tc;
for ( i = 1; i <= x ; i++)
{
tr = new TableRow();
for ( j = 1; j <= i; j++)
{
tc = new TableCell();
tc.BorderWidth = 1;
tc.Text = i + "*" + j + "=" + (i * j);
tr.Cells.Add(tc);
}
Table1.Rows.Add(tr);
}
}
protected void Page_Load(object sender, EventArgs e)
{
mul(9);
}
protected void Button1_Click(object sender, EventArgs e)
{
Table1.Rows.Clear();
int a = Convert.ToInt32(TextBox1.Text);
mul(a);
}
}
用的vs2008,web标准控件,可以显示9*9的,初始化正确,问什么不能根据输入数值显示
[解决办法]
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { mul(9); } }