|
-
June 11th, 2012, 10:09 AM
#1
how to retrieve contents from dynamically created textboxes
hello im creating textboxes and their number depends on the contents of a dropdownlist.
Code:
protected void dropDownList_SelectedIndexChanged(object sender,EventArgs e)
{
int number=int.parse(dropdownitem.Text);
for(int i=0;i<number;i++)
{
TextBox tb=new TextBox();
tb.ID="tb"+i.ToString();
Panel1.Controls.Add(tb); //placing the textboxes on a panel
}
}
now i want to retrieve the data from these textboxes. but my approach is not clear
Code:
protected void button1_Click(object sender,Eventargs e)
{
for(int i=0;i<Request.Form.Count;i++)
{
string strid="tb"+i.ToString();
string value=Request.Form[strid].ToString();
}
}
this is definitely not working.can you suggest something that serves my purpose? thanks in advance
-
June 12th, 2012, 01:35 AM
#2
Re: how to retrieve contents from dynamically created textboxes
You need to locate and init the control before you can use it
PS.. I'm a vb guy so this may not work right of the bat...
Code:
protected void button1_Click(object sender,Eventargs e)
{
for(int i=0;i<Request.Form.Count;i++)
{
string strid="tb"+i.ToString();
control txtboxinput = Panel1.FindControl(strid);
string value=txtboxinput.Text.ToString();
}
}
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|