473,404 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

get values of dynamically created textboxes

56
Hello everyone,
Below is my code:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
touchpay.fillcombo(dpwcompany, "select company_id,company_name from company_master");
}
}
protected void btnadd_Click(object sender, EventArgs e)
{
for(int i=0; i<Convert.ToInt32(DropDownList1.SelectedValue); i++)
{
TextBox textBox =(TextBox)Panel1.FindControl("myTextBox" + i);
if (textBox != null)
{
touchpay.exce("Insert into card_pin_master(company_id,card_type,pin,card_id) values('" + dpwcompany.SelectedValue + "','" + dpwtype.SelectedValue + "','" + textBox.Text+ "',"+dpwcardname.SelectedValue+"')");
}
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
for (int x = 0; x < Convert.ToInt32(DropDownList1.SelectedValue); x++)
{
TextBox textarray = new TextBox();
textarray.ID = "myTextBox" + x.ToString();

Label lb = new Label();
lb.Text = textarray.ID;
Panel1.Controls.Add(textarray);
Panel1.Controls.Add(lb);
}
}

protected void dpwtype_SelectedIndexChanged(object sender, EventArgs e)
{
touchpay.fillcombo(dpwcardname, "select card_name,card_id from card_info_master where company_id='" + dpwcompany.SelectedValue + "' and card_type='" + dpwtype.SelectedValue + "'");
}


In this code,If u select 4 in dropdownlist then 4 textbox is created.Now i want to insert the values of that textbox in database.Then tell me how can i get the values of that textboxes.

thanx in advance..
Jan 10 '08 #1
1 1429
kunal pawar
297 100+
THis is not feasible method but u can try this, as your text box having same starting name "myTextBox"
After submit your page, textbox values pass through Form/Querystring collection. in that you need to search "myTextBox".
Jan 10 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mark Broadbent | last post by:
This one has got me absolutely stumped. At work I have created a simple web form that gets data from a sql backend and puts this to a dataset. I have an edit button that when clicked will set...
3
by: SD | last post by:
Hello, I have a form that has a panel container where I'm adding textboxes dynamically based on a query to database, so I'm looping through the records. The problem I have is that once built,...
5
by: \A_Michigan_User\ | last post by:
I'm using asp.net/vb.net/ado.net to create a very simple user interface. (Everything works if I use STATICALLY created textBoxes... but not when I make them DYNAMICALLY.) 1. Execute a SQL...
5
by: BLACKDOG157 | last post by:
I've made a form with a variable number of textboxes. The user fills them out, and then I need to pick up the values he has filled in. The number of textboxes vary depending on a value that the...
17
by: cygsoft | last post by:
Hi I have created a dynamic row and inserted the values into the cells of those rows from textboxes. Now I have to edit those values stored in the rows. At the end of each row created dynamically...
1
by: Anuj Sharma | last post by:
Hi all, i surf websites from the past 10 hours, but i m not getting any good answer, about my problem "How can i get values from dynamically created textboxes" if any one knows the best, reply...
2
by: phpachu | last post by:
Hi, I hav created a group of textboxes using a loop and its names are unique and names are assigned using variable ( like <input type=text name=$name1>). Then How can i retrieve the values in...
1
by: JFKJr | last post by:
Hello everyone, the following Access VBA code opens an excel file and creates textboxes in a given range of cells dynamically. The code attaches "MouseUP" and "Exit" events to the textboxes (using...
2
by: bharathi228 | last post by:
my code for retrieving values from database Dim da As New SqlDataAdapter("select parameter_name,parameter_units from sys_params", con) If con.State = ConnectionState.Closed Then con.Open()...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.