请问有没有办法动态添加一个组件到WEB FROM上 http://expert.csdn.net/Expert/topic/1945/1945697.xml?temp=.2097437 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 使用如下代码并不能添加成功, 请继续: Button newbutton = new Button(); newbutton.ID = "aaa"; newbutton.Text = "AAA"; Page.Controls.Add(newbutton); protected System.Web.UI.WebControls.Table Table1; private void Page_Load(object sender, System.EventArgs e){ string[] n = new String[5]; n[0] = "hehe"; n[1] = "heihei"; n[2] = "hengheng"; n[3] = "kao"; n[4] = "faint"; for(int i=0;i<n.Length;i++) { Button bt = new Button(); bt.Width = 100; bt.ID = n[i]; bt.Text = n[i]; //添加事件 //bt.Attributes.Add("onclick","return NeedHelp();"); int cellIndex = i%3; int rowIndex = i/3; if(cellIndex==0) { TableRow row = new TableRow(); Table1.Rows.Add(row); } TableCell cell = new TableCell(); TableRow currentRow = Table1.Rows[rowIndex]; cell.Controls.Add(bt); currentRow.Cells.Add(cell); }} 我其实是想通过代码来控制对象的位置(left, top), 难道没能办法吗? 大家看看我这段代码问题在哪里? 加密问题求助 急 Rdlc文件内容不显示? 窗体间传递数据时,出现“****引用封送的字段,访问上面的成员可能导致异常”????? C#.net 中访问Sql数据库SqlDataAdapter,出现问题:超时时间已到... ConfigurationSettings如何动态对配置 关于面向对象设计,聚合如何设计? 请高手帮我看看这个c#程序有什么错 极度郁闷中,辛辛苦苦做的软件,竟然无人认可??请大家帮我分析一下! 征求常用的软件加密办法 关于ADO的问题,OpenSchema的参数值应该怎样设置 寻:C#调用API函数的书籍
Button newbutton = new Button();
newbutton.ID = "aaa";
newbutton.Text = "AAA";
Page.Controls.Add(newbutton);
private void Page_Load(object sender, System.EventArgs e)
{
string[] n = new String[5];
n[0] = "hehe";
n[1] = "heihei";
n[2] = "hengheng";
n[3] = "kao";
n[4] = "faint";
for(int i=0;i<n.Length;i++)
{
Button bt = new Button();
bt.Width = 100;
bt.ID = n[i];
bt.Text = n[i];
//添加事件
//bt.Attributes.Add("onclick","return NeedHelp();");
int cellIndex = i%3;
int rowIndex = i/3;
if(cellIndex==0)
{
TableRow row = new TableRow();
Table1.Rows.Add(row);
}
TableCell cell = new TableCell();
TableRow currentRow = Table1.Rows[rowIndex];
cell.Controls.Add(bt);
currentRow.Cells.Add(cell);
}
}