I\'ve been banging my head against this all morning, so hopefully I can get some help. Essentially I\'m having issues getting values from some textbox controls I\'m creating
Create Dynamic TextBoxes and add it to a asp panel so that you can access it easily.
Here is the ASP.NET design elements.
C# Code to generate Dynamic textboxes
protected void create_dynamic_text(object sender, EventArgs e)
{
int num = 5; // you can give the number here
for (int i = 0; i < num;i++ )
{
TextBox tb = new TextBox();
tb.ID = "txt_box_name" + i.ToString();
tb.CssClass = "add classes if you need";
tb.Width = 400; //Manage width and height
panel.Controls.Add(tb); //panel is my ASP.Panel object. Look above for the design code of ASP panel
}
}
C# Code to Take Values
protected void reade_values(object sender, EventArgs e)
{
int num=5; // your count goes here
TextBox tb = new TextBox();
for (int i = 0; i < num; i++)
{
tb=(TextBox)panel.FindControl("txt_box_name"+i.ToString());
string value = tb.Text; //You have the data now
}
}
}