473,657 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamic controls creation - issue

Sri
Hi,

I need to create controls dynamically on click of a button.
When the user click on a button, I need to create a text box, dropdown
list and check box in a row. Additional row has to be created with the
controls on each click of the button. I am able to recreate the
controls each time on Page_load event by maintaining the number of rows
as a Viewstate variable. But I am not able to retain the values entered
in the textbox/dropdownlist. How to retain the values in the
dynamically created controls? I tried with having ViewState variable
for each and every control. But somehow it is not retained. Please let
me know if there is any way to achieve this.

Thanks
Sri

Jun 19 '06 #1
1 1058
Hi

I had a similar problem which I fixed.

I would suggest that you put your text box, dropdown and check box in a
user control and add that dynamically. Instead of just doing simply
Controls.Add(my Control), you need to load the "whatever.a scx" using:

myControl = LoadControl("wh atever.ascx");
Page.Controls.A dd(control);

Make sure you do this in your CreateChildCont rols() method on your
page. You should then find that the controls maintain their state and
so on without your having to intervene manually. If they don't, there's
something you're not doing right...

Hope this helps,

Mark
Sri wrote:
Hi,

I need to create controls dynamically on click of a button.
When the user click on a button, I need to create a text box, dropdown
list and check box in a row. Additional row has to be created with the
controls on each click of the button. I am able to recreate the
controls each time on Page_load event by maintaining the number of rows
as a Viewstate variable. But I am not able to retain the values entered
in the textbox/dropdownlist. How to retain the values in the
dynamically created controls? I tried with having ViewState variable
for each and every control. But somehow it is not retained. Please let
me know if there is any way to achieve this.

Thanks
Sri


Jun 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
16239
by: charliewest | last post by:
I need to create textboxes in real-time, the actual number of which is determine by a result from a database query. I have been able to create the controls, and then add them to the ASPX page. However, when i submit the page, i am unable to read the values entered in these new textboxes. I have first tried to use System.Web.UI.WebControls.TextBox namespace, however, i was unable to read any value from my textboxes using the following...
2
2549
by: Dave Williamson | last post by:
When a ASPX page is created with dynamic controls based on what the user is doing the programmer must recreate the dynamic controls again on PostBack in the Page_Load so that it's events are wired and are called like a static control. Here is the problem that I need to solve. The processing overhead that occurs to determine what dynamic controls need to be added involves business logic and a query or queries of data in a sql server...
1
1200
by: Homam | last post by:
So I have a composite paging control that shoulld be positioned on the page like this: PagNav ResultSetDisplay PagNav I know that I can't resuse the PagNav more than once in the form, so I instantiate a couple of instances, PagNavTop and PagNavBottom, and thus I end up with:
7
2553
by: msdev | last post by:
Hello, I am creating my own webbrowser to learn VB .Net. I am stuck on an issue with regards to dynamically-created controls, in this case tabs on a tabcontrol and webbrowsers created within each new tab. Using AddHandler in a class, I can get the delegate Sub to display the name of the webbrowser that has been clicked (by using msgbox(sender.tag), where I set the .tag value when creating the control). What I need to be able to do is...
0
1131
by: Paul | last post by:
Hi! I have been wondering about a design issue for some time now and hope someone can help sort this one out for me. Say you have to create some webcontrols dynamically. Each controls creation is dependent on another’s selected value. That is, you can’t create control B if you don’t know the value of control A. There is no problem this far. I’ve done some testing and if I always create the control in Page_Init, ASP.NET has...
0
8402
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8829
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8734
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7341
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6172
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.