static int i = 0;
static List<int> count = new List<int>();
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void CreateChildControls()
{
base.CreateChildControls();
RebuildFields();
}
void RebuildFields()
{
foreach (int j in count)
{
UserControl uc = (UserControl)Page.LoadControl("Field.ascx");
uc.ID = "uc" + j;
pnlField.Controls.Add(uc);
LiteralControl lc = new LiteralControl();
lc.ID = "lc" + j;
lc.Text = "<br/>";
pnlField.Controls.Add(lc);
Button btnAddField = new Button();
btnAddField.ID = "btnAddField" + j;
btnAddField.Text = "+";
btnAddField.Click += btnAddField_Click;
pnlField.Controls.Add(btnAddField);
lc = new LiteralControl();
lc.ID = "lc_" + j;
lc.Text = "<br/>";
pnlField.Controls.Add(lc);
}
}
protected void btnAddField_Click(object sender, EventArgs e)
{
UserControl uc = (UserControl)Page.LoadControl("Field.ascx");
i = i + 1;
count.Add(i);
uc.ID = "uc" + i;
pnlField.Controls.Add(uc);
LiteralControl lc = new LiteralControl();
lc.ID = "lc" + i;
lc.Text = "<br/>";
pnlField.Controls.Add(lc);
Button btnAddField = new Button();
btnAddField.ID = "btnAddField" + i;
btnAddField.Text = "+";
btnAddField.Click += btnAddField_Click;
pnlField.Controls.Add(btnAddField);
lc = new LiteralControl();
lc.ID = "lc_" + i;
lc.Text = "<br/>";
pnlField.Controls.Add(lc);
}
}
static List<int> count = new List<int>();
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void CreateChildControls()
{
base.CreateChildControls();
RebuildFields();
}
void RebuildFields()
{
foreach (int j in count)
{
UserControl uc = (UserControl)Page.LoadControl("Field.ascx");
uc.ID = "uc" + j;
pnlField.Controls.Add(uc);
LiteralControl lc = new LiteralControl();
lc.ID = "lc" + j;
lc.Text = "<br/>";
pnlField.Controls.Add(lc);
Button btnAddField = new Button();
btnAddField.ID = "btnAddField" + j;
btnAddField.Text = "+";
btnAddField.Click += btnAddField_Click;
pnlField.Controls.Add(btnAddField);
lc = new LiteralControl();
lc.ID = "lc_" + j;
lc.Text = "<br/>";
pnlField.Controls.Add(lc);
}
}
protected void btnAddField_Click(object sender, EventArgs e)
{
UserControl uc = (UserControl)Page.LoadControl("Field.ascx");
i = i + 1;
count.Add(i);
uc.ID = "uc" + i;
pnlField.Controls.Add(uc);
LiteralControl lc = new LiteralControl();
lc.ID = "lc" + i;
lc.Text = "<br/>";
pnlField.Controls.Add(lc);
Button btnAddField = new Button();
btnAddField.ID = "btnAddField" + i;
btnAddField.Text = "+";
btnAddField.Click += btnAddField_Click;
pnlField.Controls.Add(btnAddField);
lc = new LiteralControl();
lc.ID = "lc_" + i;
lc.Text = "<br/>";
pnlField.Controls.Add(lc);
}
}
No comments:
Post a Comment