展开全部
您好:您这样:
protected void Page_Load(object sender, EventArgs e)
{
TextBox txtbx= null;
DropDownList ddl = null;
for (int i = 0; i < 4; i++)
{
txtbx= new TextBox();
txtbx.ID = "mytxt" + i;
txtbx.Text = "mytxt" + i;
pnlButton.Controls.Add(txtbx);
ddl= new DropDownList();
ddl.ID = "mydropdown " + j;
ddl.Text = "mydropdown " + j;
ddl.Items.Add("Hii");
ddl.Items.Add("Hello");
ddl.AutoPostBack = true;
ddl.SelectedIndexChanged += new EventHandler(ddl_Click);
pnlButton.Controls.Add(ddl);
Literal lit = new Literal();
lit.Text = "</br></br>";
pnlButton.Controls.Add(lit);
}
}
protected void Page_Load(object sender, EventArgs e)
{
TextBox txtbx= null;
DropDownList ddl = null;
for (int i = 0; i < 4; i++)
{
txtbx= new TextBox();
txtbx.ID = "mytxt" + i;
txtbx.Text = "mytxt" + i;
pnlButton.Controls.Add(txtbx);
ddl= new DropDownList();
ddl.ID = "mydropdown " + j;
ddl.Text = "mydropdown " + j;
ddl.Items.Add("Hii");
ddl.Items.Add("Hello");
ddl.AutoPostBack = true;
ddl.SelectedIndexChanged += new EventHandler(ddl_Click);
pnlButton.Controls.Add(ddl);
Literal lit = new Literal();
lit.Text = "</br></br>";
pnlButton.Controls.Add(lit);
}
}
追问
能不能说一下具体的添加控件的步骤,我还是不会。。。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询