473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

adding textboxes dynamically

hi ,
i am geo.please any one help me to slove this

i have one panel , table, and a button. i want to add 2 new textboxs dynamically when i clicks on the button. if i click it again another 2 textbox should come. but if i entered any thing on previous textboxs it will not deleted at the time of clicking the button.please help me. i am able to add the row each time the button clicks , that code is follows, there is only two columns in the table. it is in asp.net using C#
Expand|Select|Wrap|Line Numbers
  1.  
  2. int b = 0;
  3. TextBox txtBox;
  4.  
  5.  
  6. protected void btnAdd_Click(object sender, EventArgs e)
  7. {
  8. b = b + 1;
  9. Session["val"] = b;
  10. int count=0;
  11.  
  12. for (int i = 0; i < b; i++)
  13. {
  14. TableRow tr = new TableRow();
  15. //2 is to count the columns
  16. for (int j = 0; j < 2; j++)
  17. {
  18. TableCell tc = new TableCell();
  19. txtBox = new TextBox();
  20. if (j == 1)
  21. txtBox.ID = "txt" + count.ToString();
  22. txtBox.Width = 315;
  23. }
  24. txtBox.EnableViewState = true;
  25. // Add the control to the TableCell
  26. tc.Controls.Add(txtBox);
  27. // Add the TableCell to the TableRow
  28. tr.Cells.Add(tc);
  29. }
  30. // Add the TableRow to the Table
  31. Table1.Rows.Add(tr);
  32. }
  33. }
  34.  
please help me to solve the problem
Jul 14 '08 #1
5 947
DrBunchman
979 Expert 512MB
Moved to .NET Forum.
Jul 14 '08 #2
kenobewan
4,871 Expert 4TB
Sounds like you are trying to avoid a post back, !Is.PagePostback. HTH.
Jul 14 '08 #3
hi ,

is it possible to avoid postback? What is HTH?

Sounds like you are trying to avoid a post back, !Is.PagePostback. HTH.
Jul 15 '08 #4
kenobewan
4,871 Expert 4TB
Yes it is with !Is.PagePostback. Suggest check out MSDN.
Jul 15 '08 #5
Curtis Rutland
3,256 Expert 2GB
Page.IsPostBack is what you need to look at.

HTH: Hope That Helps.
Jul 15 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Shayer | last post by:
Hello I want to add some dynamic control in the win form when i press a button I write the following line of code. But the problem is instead of displaying 10 textbox it display 9 textboxes.But...
6
by: Dany P. Wu | last post by:
Hi everyone, I created a page which contains a two-column table. The first column has a bunch of labels, and the second a bunch of textboxes. Here's the code: ...
0
by: Sileesh | last post by:
Hi I have html table and a Button in an Aspx page. I am adding one row with some textboxes to Html table each time i click on the Button thru Javascript. Now problem is when when i try to...
6
by: Dany P. Wu | last post by:
Hi everyone, I created a page which contains a two-column table. The first column has a bunch of labels, and the second a bunch of textboxes. Here's the code: ...
4
by: Alex Denton | last post by:
Okay, here's my problem: I need to populate different fields in an HTML table with TextBoxes. For example, if I had 3 columns "Name", "Address", and "City"; I need to have a TextBox in all of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.