怎么把textbox控件添加在编程产生的table里

哈哈之水 2009-03-05 06:19:18
如题请问生成表格的同时在表格中产生textbox。生成表格是按编程方式产生的。 我只做得出来给出行和列 产生表格。。无法在表格中再加入textbox求教!我的代码如下
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class table : System.Web.UI.Page
{

protected void button1_Click(object sender, EventArgs e)
{
int numr= int.Parse(ListBox1.SelectedItem.Value);
int numd= int.Parse(DropDown1.SelectedItem.Value);
for (int i = 0; i < numr; i++)
{
TableRow r = new TableRow();
for (int j = 0; j < numd; j++)
{
TableCell c = new TableCell();
TextBox B = new TextBox(); 这行不对 只是在添加text里想的。想到这里 不知道对不对,求教
c.Controls.Add(new LiteralControl("行" + i.ToString() + ", 列" + j.ToString()));
r.Cells.Add(c);
}

table1.Rows.Add(r);


}
}
}
其中用了listbox和dropdwon2个控件 。
...全文
47 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
哈哈之水 2009-03-05
  • 打赏
  • 举报
回复
发多了。。。

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧