Click here to Skip to main content
16,018,347 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have generated dynamic textbox..i want to get id of dynamically generated textbox and insert value into database from that textbox...so can anybody plz help me..
Posted
Updated 22-May-13 22:23pm
v2

While generating the controls you can set the ID for it. Like:
C#
TextBox TextBox1 = new TextBox();
TextBox1.ID = "TextBox1"; //Setting ID for TextBox
//Now you add the control to your page



--Amit
 
Share this answer
 
just type cast your 'object' argument of the event in which you want to save the id in database.

ex:
textbox_TextChanged(object sender,eventargs e)
{

TextBox txtCtrl=(TextBox)sender;

txtCtrl.ClientId or txtCtrl.Id will contain the id u wanted.

}



but beforly hook the dynamically generated Control with 'TextChanged' event
hope this helps.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900