.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

cannot access runtime control

Posted By: Irfad C     Posted Date: November 11, 2009    Points:2   Category :C#
pls help me sir,
in my project i want to create table of controls at runtime, so i use the method given below

public void createcontrol(int id)
{
TableRow r = new TableRow();

TableCell d = new TableCell();
Label empname = new Label();
empname.Text="irfad";
empname.ID = "empname" + id.ToString();
d.Controls.Add(empname);


TableCell c = new TableCell();
TextBox openingbalance = new TextBox();
openingbalance.ID = "openingbalance" + id.ToString();
c.Controls.Add(openingbalance);
r.Cells.Add(c);
Table1.Rows.Add(r);
}
so in each row the id of each control will be change, ie id of the label empname like, empname0, empname1, etc.

here i have a problem like i'm not able to access these controls,i want to access each controls seperately, i hope think we can access the controls based on control id. But here it is not recognized.
what will i do sir,
please help me sir.............

Responses
Author: Amit Mehra             
Posted Date: November 11, 2009     Points: 5   

Hi Irfad,

Loop Thru the page to get the desired control to get the dynamically generated control value..

Page.FindControl("empname"+id.ToString())


Thanks
Amit

Thanks,
Amit
Please "Mark As Answer " if this post help you.


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend