Click here to Skip to main content
16,016,925 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Over a button Click a panel get display with 5 or more textBox (TextBox is created by for loop according to no of row affected by query.) and one button.
Just
I want's that when i click over panel button then the value of textBox get Stored inside a string seperated by ','.

I did that but The textboxes are lossing there value at roundTrip.
I am not able to handle this so plz help me...
Byyy.

protected void ButtoncreateTextBox_Click(object sender, EventArgs e)
   {
       for (int i = 0; i < 5; i++)
       {
           TextBox t = new TextBox();
           t.ID = "TextBox" + i.ToString();
           Panel1.Controls.Add(t);
       }

   }

I have to retrive data form these text box(added in panel) over other button click.
Posted
Updated 15-Jun-10 23:37pm
v3
Comments
Niklas L 16-Jun-10 5:09am    
Maybe you could supply a code snippet so people know what you have done?

When you add dynamic control then you have to take care of their state, by default the state is not maintained. Simplest way to retrieve the value of the dynamic control on post back is to use Request.Form[“NameOfTheControl”]. The other way is to write your custom control and handle the view state by yourself.

You can also check following CP article.
Retaining State for Dynamically Created Controls in ASP.NET applications[^]



Once you are able retrieve the values at server side its a simple task to make them comma separated.

[Edit]

Found one more useful article.

http://www.4guysfromrolla.com/articles/092904-1.aspx[^]
 
Share this answer
 
v2
So at roundTrip u better set for PostBack property for the Page Load and try it....
 
Share this answer
 

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