using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class TEXT1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
/* Label lbl;
TextBox txt;
for (int i = 0; i <= 3; i++)
{
lbl = new Label();
txt = new TextBox();
lbl.Text = "Label" + (i).ToString() + " ";
// txt.Text = "TextBox" + (i).ToString();
lbl.ID = "Label" + i.ToString();
txt.ID = "TextBox" + i.ToString();
txt.EnableViewState = true;
Panel1.Controls.Add(lbl);
Panel1.Controls.Add(txt);
//_textBoxes.Add(txt);
Panel1.Controls.Add(new LiteralControl("<br /><br />"));
}*/
//divText.InnerText
}
protected void Button1_Click(object sender, EventArgs e)
{
foreach (Control c in Panel1.Controls)
{
if (!string.IsNullOrEmpty(c.ID))
{
if (c.ID.ToLower().Contains("label"))
{
lblMessage.Text += ((Label)c).Text + ":";
}
if (c.ID.ToLower().Contains("text"))
{
if (!string.IsNullOrEmpty(((TextBox)c).Text))
{
lblMessage.Text += ((TextBox)c).Text + ",";
}
}
}
}
}
protected void ListBox2_SelectedIndexChanged(object sender, EventArgs e)
{
Label lbl;
TextBox txt;
for (int i = 0; i <= 3; i++)
{
lbl = new Label();
txt = new TextBox();
lbl.Text = "Label" + (i).ToString() + " ";
// txt.Text = "TextBox" + (i).ToString();
lbl.ID = "Label" + i.ToString();
txt.ID = "TextBox" + i.ToString();
txt.EnableViewState = true;
Panel1.Controls.Add(lbl);
Panel1.Controls.Add(txt);
//_textBoxes.Add(txt);
Panel1.Controls.Add(new LiteralControl("<br /><br />"));
}
}
WHEN THE CODE INSIDE ListBox2_SelectedIndexChanged FUNCTION PUT IN PAGELOAD FUNCTION.. VALUE OF TEXT BOX SHOW... BT WHEN USED IN ListBox2_SelectedIndexChanged
..VALUE OF TEXT BOX DOESNT SHOW..WHY