请问 如果有一个文本框和一个按钮 当我在文本框里输入数字时 单击按钮之后 页面上会自动生成与数字相对应的表格 如何实现 谢谢了
解决方案 »
- 急!!GridView怎么获取指定列的值?
- 在服务器脚本中执行confirm js问题
- Ajax AutoComplete 如何对匹配结果进行筛选?
- C# 中default 后面不加break会报错?
- GridView 行高度的问题
- 求几个正则表达式-超级无敌的 简单
- vs2003 datagrid里混用checkbox,我现在想要取出选中的行的id主键
- 在插入数据库值时碰到的问题
- [color=#FF0000]超级难的问题呀`~~~~~~~~~~分都问没了都没解决 ~5555555[/color]
- 水晶报表导出问题
- 应用程序连接服务器数据库的安全问题
- Response.Expires有什么作用?
string table="<table border=0>"``````
最好将生成的字符串加起来Response()出来
for (int i=0 ;i<int.Parse(TextBox1.Text);i++)
{
Label1.Text += "<tr><td>测试数据</td></tr>";
}
Label1.Text += "</table>";
把上面的 Label1.Text = "<table>";
改成
Label1.Text = "<table border=1 >";
就能看到表格了
{
int a = Convert.ToInt32(this.TextBox6.Text);
for (int ii = 0; ii < a; ii++) {
Label Label1 = new Label();
Label1.Text = "<table border=1 >";
for (int i = 0; i < a; i++)
{
Label1.Text += "<tr><td>测试数据</td></tr>";
}
Label1.Text += "</table>"; }
}
代码是这样的 出不来啊
代码如下
public void qq() {
string str = "";
str += "<table border=1 cellpadding=0 cellspacing=0 width=250px height=140px>";
str += "<tr><td>id</td><td>name</td>";
str += "<td>age</td><td>sex</td></tr>";
str += "</table>";
this.div5.InnerHtml = str;
}
Label1.Text = "<table border=1>";
for (int i=0 ;i<int.Parse(TextBox1.Text);i++)
{
Label1.Text += "<tr><td>测试数据</td></tr>";
}
Label1.Text += "</table>";
在我机器上是成功的,要不你用已创建的label试,可能是你动态创建label有问题
Cs:public void MakeTable()
{
int iRow = int.Parse(txtRow.Text);
int iCol = int.Parse(txtCol.Text);
string strTable = "<table>";
for(int i = 0 ;i < iRow ;i++ ){
strTable += "<tr>";
for(int j = 0 ;j < iCol ; j++ ){
strTable += "<td> </td>";
}
strTable += "</tr>";
} strTable += "</table>"; Response.Write(strTable);
}
protected void Button1_Click (object sender, System.EventArgs e)
{
// Total number of rows.
int rowCnt;
// Current row count.
int rowCtr;
// Total number of cells per row (columns).
int cellCtr;
// Current cell counter
int cellCnt; rowCnt = int.Parse(TextBox1.Text);
cellCnt = int.Parse(TextBox2.Text); for(rowCtr=1; rowCtr <= rowCnt; rowCtr++) {
// Create new row and add it to the table.
TableRow tRow = new TableRow();
Table1.Rows.Add(tRow);
for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++) {
// Create a new cell and add it to the row.
TableCell tCell = new TableCell();
tCell.Text = "Row " + rowCtr + ", Cell " + cellCtr;
tRow.Cells.Add(tCell);
}
}
}
比如我输入6 点击按钮就会出现6个table
代码如下
Label1.Text = "<table border=1 cellpadding=0 cellspacing=0 width=250px height=140px>";
for (int i = 0; i < int.Parse(TextBox1.Text); i++)
{
Label1.Text += "<tr><td>id</td><td>name</td><td>age</td><td>sex</td></tr>";
Label1.Text += "<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>";
}
Label1.Text += "</table>";
现在能出现 但是表格没有分开 请大家帮忙