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



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

unlimited textbox array

Posted By: Irfad C     Posted Date: November 22, 2009    Points:2   Category :C#
Sir, i want to create set of textboxes and other controls at runtime, iam using asp.net with c#. in c#
i use this code
TextBox[] Name=new TextBox[];//
TextBox[] ContactNo=new TextBox[];;
TextBox[] Company=new TextBox[];;
this ddeclaration is at global section,in page_load event i wnat to create these controls, and only that time i able to know the size of this text box arrays. because textbox array size is depends on the number of employees in the database it can vary accordingly.These textboxes i want to access in different methods so i should place this as globally. so in my case i have no way to specify the size of the textbox. is there any possible to give textbox array as unlimitted.pls help me sir

Responses
Author: Rahul             
Posted Date: November 22, 2009     Points: 5   

Hi Irfad,

You can try like this no need to declare global array

For Creating TextBox you can use this function

private TextBox createRadio(string title, string index)
{
TextBox txt= new TextBox ();
txt.ID = index.ToString();
txt.Text = title;

return txt;
}


to retrive the Runtime Control value try this code

protected void btnGetData_Click(object sender, EventArgs e)
{


Control ctr = Page.FindControl("1");
foreach (Control c in pnlChoice.Controls)
{
if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox") && c.ID != null)
{
TextBox txt = c as TextBox;
if(txt !=null)
{
string str = txt.Text;
}

}

}

}




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