I made a dynamic TextBox and a Dynamic Button.. I would like to add an event on Dynamic Button to change the textbox text when clicked. What I want is when I made TextBox1 text "1" into "2" the TextBox having "2" will become "1". below is my code for page2. Page 1 is just a CheckBoxList consist of items to be passed on page2 DropDownList.
.cs Page2
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string[] arr = (string[])Session["checkedarray"];
for (int i = 0; i < int.Parse(Session["numofchecked"].ToString()); i++)
{ DropDownList1.Items.Add(arr[i].ToString());
}
}
//populate and make text / label
for (int i = 0; i < DropDownList1.Items.Count; i++)
{
this.form1.Controls.Add(new LiteralControl("<br/>"));
TextBox TextBox1 = new TextBox();
TextBox1.ID = "TextBox" + i.ToString();
TextBox1.Text = "" + (i + 1);
TextBox1.Width = 18;
this.form1.Controls.Add(TextBox1);
Button btnup = new Button();
btnup.ID = "btnUp" + i.ToString();
btnup.Text = "▲";
btnup.CssClass = "add";
this.form1.Controls.Add(btnup);
Button btndown = new Button();
btndown.ID = "btndown" + i.ToString();
btndown.Text = "▼";
btndown.CssClass = "sub";
this.form1.Controls.Add(btndown);
Label Label1 = new Label();
Label1.ID = "Label" + i.ToString();
Label1.Text = " " + DropDownList1.Items[i].ToString();
this.form1.Controls.Add(Label1);
this.form1.Controls.Add(new LiteralControl("<br/>"));
}