Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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 22-May-13 22:08pm
Edited 22-May-13 22:23pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

--Amit
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 303
1 Sergey Alexandrovich Kryukov 291
2 RyanDev 75
3 nv3 60
4 PhilLenoir 50
0 Sergey Alexandrovich Kryukov 6,691
1 OriginalGriff 6,119
2 CPallini 2,473
3 Richard MacCutchan 1,697
4 Abhinav S 1,560


Advertise | Privacy | Mobile
Web02 | 2.8.140821.2 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100